FLUTTER ECOSYSTEM

hcbpassos/double_back_to_close_app

一个 Flutter 包,允许 Android 用户通过连续按两次返回键来关闭应用。

double_back_to_close_app 项目封面
Stars
58
Forks
17
最近推送(UTC)
2025年1月13日
项目状态
未归档
Hugo Passos GitHub avatar
GITHUB User

Hugo Passos ↗

w.wiki/j6C

@nubank
语言DartSwiftObjective-C

技术话题

此仓库发布的插件

使用的依赖

依赖清单 3 项
  • flutter{"sdk":"flutter"}
  • flutter_test开发依赖{"sdk":"flutter"}
  • lints开发依赖^5.1.1

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

展开 / 收起项目 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.