Skip to content

Instantly share code, notes, and snippets.

@Slowhand0309
Created October 13, 2020 08:31
Show Gist options
  • Save Slowhand0309/3cb476943840eb61d4be6abdb74851d7 to your computer and use it in GitHub Desktop.
Save Slowhand0309/3cb476943840eb61d4be6abdb74851d7 to your computer and use it in GitHub Desktop.
[Handling Back Button in Flutter] #Flutter
class MyApp extends StatelessWidget {
Future<bool> _onBackPressed() {
// true -> go back
// false -> back cancel
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('title'),
),
body: WillPopScope(
onWillPop: _onBackPressed,
child: Container(),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment