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.
- Allows conditional exit on iOS.
In your Flutter project, add the double_back_to_exit dependency to your pubspec.yaml file:
dependencies:
double_back_to_exit: ^1.2.0Import the package in your Dart file:
import 'package:double_back_to_exit/double_back_to_exit.dart';
Wrap your main widget with the DoubleBackToExitWidget:
DoubleBackToExitWidget(
snackBarMessage: 'Press back again to exit',
child: MaterialApp(
// Your app content here
),
)To ensure the double back press functionality works correctly on Android, add the following line to the tag in your AndroidManifest.xml file:
<application
android:enableOnBackInvokedCallback="true"
... >
<!-- Other configurations -->
</application>For a complete example, see the example folder.
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.