flutter_close_app

Last updated:

0 purchases

flutter_close_app Image
flutter_close_app Images
Add to Cart

Description:

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)









中文说明

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 #

Use #

Dependent

flutter pub add flutter_close_app
copied to clipboard

Or

dependencies:
flutter_close_app: ^1.0.0
copied to clipboard

Import package

import 'package:flutter_close_app/flutter_close_app.dart';
copied to clipboard
Example #

Press back 2 times to close app

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: ...
),
);
}
}
copied to clipboard

One click to close app

FlutterCloseApp.close();
copied to clipboard

Advanced usage

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: ...
),
);
}
}
copied to clipboard
Issues and feedback #
Please file issues to send feedback or report a bug. Thank you!
LICENSE #

MIT

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.