https://github.com/best-flutter/easy_alert
A package for flutter to use alert and toast within one line code.
https://github.com/best-flutter/easy_alert
Last synced: 5 months ago
JSON representation
A package for flutter to use alert and toast within one line code.
- Host: GitHub
- URL: https://github.com/best-flutter/easy_alert
- Owner: best-flutter
- License: other
- Created: 2018-09-09T09:25:30.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-01-19T12:24:52.000Z (over 6 years ago)
- Last Synced: 2025-03-28T03:51:13.128Z (about 1 year ago)
- Language: Dart
- Size: 134 KB
- Stars: 32
- Watchers: 2
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# easy_alert
A package for flutter to use alert and toast within one line code.
## Getting Started
Add
```
easy_alert:
```
to your pubspec.yaml, and run `flutter packages get` in your project root directory.
## Showcases


## ROADMAP
* [x] alert
* [x] ios style alert
* [x] confirm
* [x] ios style confirm
* [x] toast
* [ ] customize alert dialog
* [ ] customize toast
* [ ] support bottom sheet.
* [x] support input
* [x] support pick and select
## Integrate with your flutter app
```
void main() => runApp(new AlertProvider(
child: new YourApp(),
config: new AlertConfig(
ok: "OK text for `ok` button in AlertDialog",
cancel: "CANCEL text for `cancel` button in AlertDialog"),
));
```
## alert
```
Alert.alert(context, title: "Hello", content: "this is a alert")
.then((_) => Alert.toast(context, "You just click ok"));
```
## confirm
```
Alert.confirm(context, title: "Hello", content: "this is a alert")
.then((int ret) =>
Alert.toast(context, ret == Alert.OK ? "ok" : "cancel"));
```
## toast
```
Alert.toast(context,"Very long toast",position: ToastPosition.bottom, duration: ToastDuration.long);
```
## pick
```
try {
int index = await Alert.pick(context,
values: widget.values, index: widget.index);
...have selected
} catch (e) {
... cancel select
}
```
```
try {
String ret = await Alert.select(context,
options: [
Option('A', 'a'),
Option('B', 'b'),
Option('C', 'c'),
],
value: 'a');
Alert.toast(context, "You just pick $ret");
} catch (e) {
Alert.toast(context, "Canceled",
position: ToastPosition.center);
}
```