OnBoarding Bottom Bar: Show a 'Get Started' on the last page

This commit is contained in:
Vishesh Handa
2019-02-16 12:05:49 +01:00
parent c12d7b69c5
commit 0a2c1d0b92

View File

@ -16,6 +16,8 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
var pageController = PageController(); var pageController = PageController();
int _currentPageIndex = 0; int _currentPageIndex = 0;
final _bottomBarHeight = 50.0;
Widget _buildPage(String text) { Widget _buildPage(String text) {
return Column( return Column(
children: <Widget>[ children: <Widget>[
@ -43,7 +45,9 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
}, },
); );
var bottomBar = Row( Widget bottomBar;
if (_currentPageIndex != pages.length - 1) {
var row = Row(
children: <Widget>[ children: <Widget>[
OnBoardingBottomButton(text: "Skip", onPressed: _finish), OnBoardingBottomButton(text: "Skip", onPressed: _finish),
Expanded( Expanded(
@ -62,6 +66,30 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
], ],
); );
bottomBar = Container(
child: SizedBox(
width: double.infinity,
height: _bottomBarHeight,
child: row,
),
color: Colors.grey[200],
);
} else {
bottomBar = SizedBox(
width: double.infinity,
height: _bottomBarHeight,
child: RaisedButton(
child: Text(
"Get Started",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.button,
),
color: Theme.of(context).primaryColor,
onPressed: _finish,
),
);
}
return Scaffold( return Scaffold(
body: Container( body: Container(
width: double.infinity, width: double.infinity,
@ -69,7 +97,7 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
child: pageView, child: pageView,
padding: EdgeInsets.all(16.0), padding: EdgeInsets.all(16.0),
), ),
bottomNavigationBar: Container(child: bottomBar, color: Colors.grey[200]), bottomNavigationBar: bottomBar,
); );
} }