Last updated:
0 purchases
handy toast
Handy toast for flutter #
A toast for flutter and easy to use!
Depends on context_holder
1. Add dependency #
dependencies:
handy_toast: ^0.0.4
copied to clipboard
2. Init context holder. #
Import context holder.
import 'package:context_holder/context_holder.dart';
copied to clipboard
Set your root app's navigatorKey with ContextHolder.key
For MaterialApp
void main() {
runApp(
MaterialApp(
/// must set the navigatorKey!!!!!!
navigatorKey: ContextHolder.key,
home: Scaffold(),
),
);
}
copied to clipboard
For CupertinoApp
void main() {
runApp(
CupertinoApp(
/// must set the navigatorKey!!!!!!
navigatorKey: ContextHolder.key,
home: Scaffold(),
),
);
}
copied to clipboard
3. Import easy toast #
import 'package:handy_toast/handy_toast.dart';
copied to clipboard
4. Use easy toast #
'handy toast'.toast();
copied to clipboard
4. Other option #
Change default style.
/// change toast background color to green with opacity.
Toast.defaultStyle = ToastStyle(
color: Colors.green.withOpacity(0.8),
);
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.