flutter_toast_plus 2.0.0
flutter_toast_plus: ^2.0.0 copied to clipboard
A highly customizable Flutter toast package that provides various types of toast notifications with beautiful animations and styles.
Flutter Toast #
A highly customizable Flutter toast package that provides various types of toast notifications with beautiful animations and styles.
Features #
- 🎨 Multiple toast types (normal, success, error, warning, info)
- 📍 Flexible positioning (top, bottom, center, corners)
- ⚡ Smooth animations
- 🎯 Progress indicator support
- 🎭 Fully customizable styles
- 🔄 Auto-dismiss with customizable duration
- 📱 Safe area aware
- 🔍 Maximum toast limit to prevent screen cluttering
Installation #
Add this to your package's pubspec.yaml
file:
dependencies:
flutter_toast_plus: ^1.0.0
Usage #
First, initialize the toast service in your app's root widget:
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Builder(
builder: (context) {
ToastService.init(context);
return MyHomePage();
},
),
);
}
}
Basic Usage #
// Show a normal toast
ToastService.show(message: 'Hello World!');
// Show a success toast
ToastService.success('Operation completed successfully!');
// Show an error toast
ToastService.error('Something went wrong!');
// Show a warning toast
ToastService.warning('Please be careful!');
// Show an info toast
ToastService.info('Here is some information.');
Customizing Position #
ToastService.show(
message: 'Custom position toast!',
position: ToastPosition.topRight,
);
Custom Styling #
final customStyle = ToastStyle(
backgroundColor: Colors.purple,
textColor: Colors.white,
icon: Icons.star,
iconColor: Colors.yellow,
borderRadius: 12.0,
padding: EdgeInsets.all(16.0),
duration: Duration(seconds: 5),
showProgressIndicator: true,
);
ToastService.show(
message: 'Customized toast!',
style: customStyle,
);
Toast Types #
ToastType.normal
- Default toast with neutral stylingToastType.success
- Green toast with check iconToastType.error
- Red toast with error iconToastType.warning
- Orange toast with warning iconToastType.info
- Blue toast with info iconToastType.custom
- Custom styled toast
Toast Positions #
ToastPosition.top
ToastPosition.center
ToastPosition.bottom
ToastPosition.topLeft
ToastPosition.topRight
ToastPosition.bottomLeft
ToastPosition.bottomRight
Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
License #
This project is licensed under the MIT License - see the LICENSE file for details.