Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/byteszero/flutter_close_app
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 一键关闭)
https://github.com/byteszero/flutter_close_app
close flutter simple
Last synced: 4 days ago
JSON representation
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 一键关闭)
- Host: GitHub
- URL: https://github.com/byteszero/flutter_close_app
- Owner: BytesZero
- License: mit
- Created: 2022-06-19T09:03:06.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-06-19T15:38:31.000Z (over 2 years ago)
- Last Synced: 2024-11-16T03:26:28.608Z (about 2 months ago)
- Topics: close, flutter, simple
- Language: Dart
- Homepage: https://pub.dev/packages/flutter_close_app
- Size: 7.99 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
A simple and flexible Flutter close app plugin
(Android press 2 times to return to close, MacOS, iOS, Windows, Linux one-click close)
- [中文说明](https://github.com/yy1300326388/flutter_close_app/tree/master/README_CN.md)
## Feature
- ✅ Press back 2 times to close app
- ✅ Custom time interval
- ✅ Customize the prompt message
- ✅ Customize matching conditions
- ✅ Support Android
- ✅ One click to close app
- ✅ Support iOS
- ✅ Support MacOS
- ✅ Support Windows
- ✅ Support Linux
## Screenshot![](https://github.com/yy1300326388/flutter_close_app/raw/master/example/images/example.gif)
## Use
- Dependent
``` shell
flutter pub add flutter_close_app
```
- Or``` ymal
dependencies:
flutter_close_app: ^1.0.0
```- Import package
``` dart
import 'package:flutter_close_app/flutter_close_app.dart';
```## Example
- Press back 2 times to close app
``` dart
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);@override
Widget build(BuildContext context) {
return FlutterCloseAppPage(
onCloseFailed: () {
// Condition does not match: the first press or the second press interval is more than 2 seconds, display a prompt message
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('Press again to exit 🎉'),
));
},
child: Scaffold(
appBar: AppBar(),
body: ...
),
);
}
}
```- One click to close app
``` dart
FlutterCloseApp.close();
```- Advanced usage
``` dart
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);@override
Widget build(BuildContext context) {
return FlutterCloseAppPage(
+ interval: 3, // Custom interval is 3 seconds
+ condition: tabIndex == 0, // Only close the app on the home page
onCloseFailed: () {
// Not the homepage does not prompt
+ if(tabIndex != 0) return;
// Condition does not match: the first press or the second press interval is more than 2 seconds, display a prompt message
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('Press again to exit 🎉'),
));
},
child: Scaffold(
appBar: AppBar(),
body: ...
),
);
}
}
```## Issues and feedback
Please file [issues](https://github.com/yy1300326388/flutter_close_app/issues) to send feedback or report a bug. Thank you!
## LICENSE
- [MIT](https://github.com/yy1300326388/flutter_close_app/blob/master/LICENSE)