1 min readAug 22, 2019
This is really a good question and I totally forget to mention this. You can refer to this WillPopScope.
class SecondHome extends StatelessWidget {
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () {
return new Future.value(true);
},
child: Scaffold(
appBar: AppBar(
title: Text('Second Home'),
),
body: Center(
child: RaisedButton(
onPressed: () {
Navigator.pop(context);
},
child: Text('Go Back'),
),
),
);
}
}
WillPopScrope expect two things
- onWillPop: You need to register a callback that will return Future<Bool>. If you return true then it will pop the Navigator else not.
- child: You put your Scaffold here.
If you have any difficulties in understanding this then let me know
Thnaks