Skip to content
pubscout

double_back_to_close_app

2.1.0, released 5 years ago by hugopassos.dev

Provides a widget that requires a double back press to exit the app on Android.

WASM-ready
$ flutter pub add double_back_to_close_app
Source repository

What it does

Wraps your UI in a widget that intercepts the Android back button. On first press it shows a SnackBar; a second press within a short interval closes the app. Handles SnackBar dismissal correctly.

AI-written summary of version 2.1.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want a simple double‑back‑to‑exit behavior on Android
  • You need a lightweight solution without native code

Skip it when

  • You need custom back‑navigation logic or iOS‑specific behavior
  • You require more advanced exit handling or multiple back‑press actions

Strengths

  • Very small and easy to integrate
  • Handles SnackBar dismissal edge cases
  • No platform‑specific setup

Weaknesses

  • Works only on Android
  • Limited customization of timing and UI
  • May conflict with other back‑button handlers

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
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')),
        ),
      ),
    );
  }
}

Alternatives

Packages that do the same job and could replace double_back_to_close_app.