A Flutter to Implement A Double Back Press To Close Functionality


A Flutter package that provides a widget to implement the double back press to exit functionality in your app.


  • Implements the double back press to exit functionality.
  • Works on both Android and iOS.
  • Customizable snackbar message.
  • Customizable duration between back presses.

Getting started

In your Flutter project, add the double_back_to_exit dependency to your pubspec.yaml file:

  double_back_to_exit: ^1.0.0


Import the package in your Dart file:

import 'package:double_back_to_exit/double_back_to_exit.dart';

Wrap your main widget with the DoubleBackToExitWidget:

  snackBarMessage: 'Press back again to exit', 
  child: MaterialApp( 
    // Your app content here 


For a complete example, see the example folder.

Additional information

For more information, check out the documentation.

If you find any issues or would like to contribute, please visit the GitHub repository.


This package is licensed under the MIT License.

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add double_back_to_exit

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

  double_back_to_exit: ^1.0.3

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:double_back_to_exit/double_back_to_exit.dart';

Download details:

Author: detextre4

Source: https://github.com/detextre4/double_back_to_exit

#flutter #widget 

A Flutter to Implement A Double Back Press To Close Functionality
1.65 GEEK