flutter_close_app 1.0.0 copy "flutter_close_app: ^1.0.0" to clipboard
flutter_close_app: ^1.0.0 copied to clipboard

A simple and flexible Flutter close app plugin,(Android press 2 times to return to close, MacOS, iOS, Windows, Linux one-click close)一款灵活的 Flutter 关闭 App 插件,包含Android 按2次返回关闭,MacOS、iOS、Windows、Linux 一键关闭)

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_close_app/flutter_close_app.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: HomePage());
  }
}

class HomePage extends StatelessWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return FlutterCloseAppPage(
      interval: 2,
      condition: true,
      onCloseFailed: () {
        // The interval is more than 2 seconds, or the return key is pressed for the first time
        ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
          content: Text('Press again to exit 🎉'),
        ));
      },
      child: Scaffold(
        appBar: AppBar(
          title: const Text('Flutter Close App'),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              const ListTile(
                leading: Icon(
                  Icons.android,
                  color: Colors.green,
                ),
                title: Text('Double back to exit app'),
              ),
              const Divider(),
              ListTile(
                leading: const Icon(
                  Icons.exit_to_app,
                  color: Colors.red,
                ),
                title: const Text('Tap close app'),
                onTap: () {
                  FlutterCloseApp.close();
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}
8
likes
115
pub points
82%
popularity

Publisher

unverified uploader

A simple and flexible Flutter close app plugin,(Android press 2 times to return to close, MacOS, iOS, Windows, Linux one-click close)一款灵活的 Flutter 关闭 App 插件,包含Android 按2次返回关闭,MacOS、iOS、Windows、Linux 一键关闭)

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_close_app