Search packages, repositories and app categories

Package detailsv2.1.0

double_back_to_close_app

A Flutter package that allows Android users to press the back-button twice to close the app.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
2.4K
Likes
334
Pub points
150

Install package

flutter pub add double_back_to_close_app

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

This Flutter package enables Android users to close the app by pressing the back button twice, improving user experience by preventing accidental exits. It works across multiple platforms including iOS, Web, macOS, Windows, and Linux, offering a consistent behavior. The package is lightweight and easy to integrate, requiring minimal setup. It provides a customizable delay between back button presses and supports both Android and iOS devices with native-like functionality.

Use cases

  • Preventing accidental app closure
  • Improving user experience on mobile devices
  • Ensuring intentional app exit
  • Supporting multi-platform apps
  • Enhancing accessibility for touch-based navigation

Key features

  • Double back press detection
  • Customizable timeout duration
  • Cross-platform compatibility
  • Minimal configuration required
  • Smooth integration with existing app flows

Suitable for

  • Mobile app developers targeting Android
  • Apps requiring intentional exit behavior
  • Developers building cross-platform applications
  • UX-focused app interfaces
  • Simple yet effective navigation enhancements

Considerations

  • May not be needed on all apps
  • Can conflict with custom back button logic
  • Requires testing on multiple platforms
  • Not applicable on non-mobile platforms like desktop
  • Potential user confusion if timeout is too short or long

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

double_back_to_close_app

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

Usage

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'),
          ),
        ),
      ),
    );
  }
}

Motivation

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.

Categories

Source repository

Projects using this package