handy_toast 0.0.4 handy_toast: ^0.0.4 copied to clipboard
A toast for flutter and very easy to use! This package depends on context_holder, another very useful package.
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
2. Init context holder. #
Import context holder.
import 'package:context_holder/context_holder.dart';
Set your root app's navigatorKey with ContextHolder.key
For MaterialApp
void main() {
runApp(
MaterialApp(
/// must set the navigatorKey!!!!!!
navigatorKey: ContextHolder.key,
home: Scaffold(),
),
);
}
For CupertinoApp
void main() {
runApp(
CupertinoApp(
/// must set the navigatorKey!!!!!!
navigatorKey: ContextHolder.key,
home: Scaffold(),
),
);
}
3. Import easy toast #
import 'package:handy_toast/handy_toast.dart';
4. Use easy toast #
'handy toast'.toast();
4. Other option #
Change default style.
/// change toast background color to green with opacity.
Toast.defaultStyle = ToastStyle(
color: Colors.green.withOpacity(0.8),
);