v2.1.0
double_back_to_close_app
A Flutter package that allows Android users to press the back-button twice to close the app.
334Likes 1.5K30-day downloads150Pub points
AndroidiOSWebmacOSWindowsLinux
A Flutter package that allows Android users to press the back-button twice to close the app.
{"sdk":"flutter"}{"sdk":"flutter"}^5.1.1English project snapshot. Visit GitHub for the latest content.
pub package ci workflow style: effective dart
A Flutter package that allows Android users to press the back-button twice to close the app.
Demo
Inside a Scaffold that wraps all your Widgets, place the DoubleBackToCloseApp passing a SnackBar:
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: DoubleBackToCloseApp(
child: Home(),
snackBar: const SnackBar(
content: Text('Tap back again to leave'),
),
),
),
);
}
}
I've implemented such solution when I answered this question in Stack Overflow, and since this feature seems to be implemented very often, I decided to extract it in a lightweight library.