my_toastify 1.0.1
my_toastify: ^1.0.1 copied to clipboard
A customizable toast notification system for Flutter. Supports banners, snackbars, and advanced styling.
Toastify #
A beautiful, customizable toast notification system for Flutter.
Supports banners, snackbars, custom icons, actions, and multiple stacking positions.
[Toastify Demo]
đ Features #
- Overlay-based toast notifications
- Top or bottom stacking
- Two styles: snackBarStyle & bannerStyle
- Custom icons, actions, and colors
- Auto-dismiss with animation
- Multiple toasts at once
- Swipe-to-dismiss gesture
đĻ Installation #
flutter pub add my_toastify
đ§ API Reference #
ToastDetails #
| Property | Type | Default | Description |
|---|---|---|---|
id |
String |
Unique ID generated if not passed |
Toast identifier for dismissing by ID |
message |
String |
â | Message text displayed in toast |
title |
String? |
null |
Optional title above message |
type |
ToastType |
ToastType.info |
Defines color/icon scheme |
position |
ToastPosition |
ToastPosition.bottom |
Where toast appears |
style |
ToastStyle |
ToastStyle.snackBarStyle |
Toast UI layout |
titleTextStyle |
TextStyle? |
Theme.of(context).textTheme.titleMedium!.copyWith(color: Colors.white) |
Custom title style |
messageTextStyle |
TextStyle? |
Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.white) |
Custom message style |
leading |
Widget? |
null |
Optional icon widget |
action |
Widget? |
null |
Optional action button |
backgroundColor |
Color? |
null |
Override default color |
borderColor |
Color? |
null |
Adds custom border |
boxShadow |
List<BoxShadow>? |
null |
Shadow customization |
duration |
Duration |
3 seconds |
Auto dismiss time |
onDismiss |
VoidCallback? |
null |
Callback when toast is dismissed |
isAutoDismissible |
bool |
true |
Set false to prevent automatic dismissal |
đĄ Example Usage #
import 'package:flutter/material.dart';
import 'package:toastify/my_toastify.dart';
void main() {
runApp(const ToastifyDemo());
}
class ToastifyDemo extends StatelessWidget {
const ToastifyDemo({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Toastify Example')),
body: Center(
child: ElevatedButton(
onPressed: () {
Toastify.show(
context: context,
title: 'Success',
message: 'Profile updated successfully!',
type: ToastType.success,
position: ToastPosition.top,
style: ToastStyle.bannerStyle,
);
},
child: const Text('Show Toast'),
),
),
),
);
}
}
âī¸ Advanced Usage Examples #
â With Leading Icon #
Toastify.show(
context: context,
title: 'Upload Complete',
message: 'Your photo has been uploaded successfully.',
type: ToastType.success,
position: ToastPosition.bottom,
style: ToastStyle.snackBarStyle,
leading: const Icon(Icons.check_circle, color: Colors.white),
);
đĢī¸ With Shadow #
Toastify.show(
context: context,
title: 'File Saved',
message: 'Document saved to local storage.',
type: ToastType.success,
position: ToastPosition.bottom,
style: ToastStyle.snackBarStyle,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.3),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
);
đĒ With Action Button #
Toastify.show(
context: context,
title: 'Undo Action',
message: 'File deleted successfully.',
type: ToastType.success,
position: ToastPosition.bottom,
style: ToastStyle.snackBarStyle,
action: TextButton(
onPressed: () {
debugPrint('Undo pressed');
},
child: const Text('Undo', style: TextStyle(color: Colors.white)),
),
);
đŦ Without Title #
Toastify.show(
context: context,
message: 'Settings have been updated.',
type: ToastType.info,
position: ToastPosition.bottom,
style: ToastStyle.snackBarStyle,
);
With onDismiss Callback #
Toastify.show(
context: context,
title: 'Info',
message: 'This toast will print when dismissed.',
type: ToastType.info,
onDismiss: () {
debugPrint('Toast was dismissed!');
},
);
Non-Auto-Dismiss Toast with Action and dismissById #
late final String toastId;
toastId = Toastify.show(
context: context,
title: 'Upload File',
message: 'Uploading in progress...',
type: ToastType.info,
position: ToastPosition.bottom,
style: ToastStyle.snackBarStyle,
isAutoDismissible: false,
action: TextButton(
onPressed: () {
Toastify.dismissById(toastId);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Upload canceled")),
);
},
child: const Text('CANCEL', style: TextStyle(color: Colors.white)),
),
);
â¤ī¸ Author #
Created by Thant Zin
- GitHub Home: https://github.com/tz-thantzin
- Repository: https://github.com/tz-thantzin/my_toastify
Copyright (Šī¸) 2025 Thant Zin