Nitish Kumar Singh
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

  1. onWillPop: You need to register a callback that will return Future<Bool>. If you return true then it will pop the Navigator else not.
  2. child: You put your Scaffold here.

If you have any difficulties in understanding this then let me know

Thnaks

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Nitish Kumar Singh
Nitish Kumar Singh

Written by Nitish Kumar Singh

Web🌐/ Mobile📱/ GraphQL / Cloud☁️ . Full-time programmer, part-time content creator, and Freelancer.

No responses yet

Write a response