FLUTTER ECOSYSTEM

hcbpassos/double_back_to_close_app

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

double_back_to_close_app project cover
Stars
58
Forks
17
Last push (UTC)
Jan 13, 2025
Project status
Active
Hugo Passos GitHub avatar
GITHUB User

Hugo Passos ↗

w.wiki/j6C

@nubank
LanguagesDartSwiftObjective-C

Technical topics

Packages published by this repository

Dependencies used

Dependency list 3 items
  • flutter{"sdk":"flutter"}
  • flutter_testDevelopment{"sdk":"flutter"}
  • lintsDevelopment^5.1.1

Original README

English project snapshot. Visit GitHub for the latest content.

Expand / collapse project README

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.