OnBoarding: The back button should not result in the app quitting

This commit is contained in:
Vishesh Handa
2019-01-17 18:12:32 +01:00
parent a2358a84cc
commit a24837314c
2 changed files with 16 additions and 2 deletions

View File

@ -183,7 +183,7 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
}, },
); );
return new Scaffold( var scaffold = new Scaffold(
key: _scaffoldKey, key: _scaffoldKey,
body: new Container( body: new Container(
width: double.infinity, width: double.infinity,
@ -202,6 +202,20 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
padding: EdgeInsets.all(16.0), padding: EdgeInsets.all(16.0),
), ),
); );
return new WillPopScope(
onWillPop: () {
if (_currentPageIndex != 0) {
pageController.previousPage(
duration: Duration(milliseconds: 200),
curve: Curves.easeIn,
);
} else {
SystemChannels.platform.invokeMethod('SystemNavigator.pop');
}
},
child: scaffold,
);
} }
void setPageInputUrlDone() { void setPageInputUrlDone() {

View File

@ -1,6 +1,6 @@
name: journal name: journal
description: A Journaling App Built on top of Git description: A Journaling App Built on top of Git
version: 1.0.0+3 version: 1.0.0+5
dependencies: dependencies:
flutter: flutter: