my_toastify 1.1.2
my_toastify: ^1.1.2 copied to clipboard
A customizable toast notification system for Flutter. Supports banners, snackbars, and advanced styling.
my_toastify #
A beautiful, customizable toast notification system for Flutter.
Supports banners, snackbars, custom icons, actions, and multiple stacking positions.
đ 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
- Customize toast animation
đĻ Installation #
$ flutter pub add my_toastify
đ§ API Reference #
ToastDetails #
| Property | Type | Default | Description |
|---|---|---|---|
| toastId | String | Unique ID generated | 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.snackBar | Toast UI layout |
| titleTextStyle | TextStyle? | textTheme.titleMedium | Custom title style |
| messageTextStyle | TextStyle? | textTheme.bodyMedium | 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 | 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 |
| animationDuration | Duration | 500ms | Duration of entrance/exit animation |
| appearCurve | Curve | Curves.easeOutBack | Curve for show animation |
| dismissCurve | Curve | Curves.easeIn | Curve for dismiss animation |
đĄ 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,
title: 'Success',
message: 'Profile updated successfully!',
type: ToastType.success,
position: ToastPosition.top,
style: ToastStyle.banner,
);
},
child: const Text('Show Toast'),
),
),
),
);
}
}
âī¸ Advanced Usage Examples #
â With Leading Icon #
Toastify.show(
context,
title: 'Upload Complete',
message: 'Your photo has been uploaded successfully.',
type: ToastType.success,
position: ToastPosition.bottom,
style: ToastStyle.snackBar,
leading: const Icon(Icons.check_circle, color: Colors.white),
);
đĢī¸ With Shadow #
Toastify.show(
context,
title: 'File Saved',
message: 'Document saved to local storage.',
type: ToastType.success,
position: ToastPosition.bottom,
style: ToastStyle.snackBar,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.3),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
);
đĒ With Action Button #
Toastify.show(
context,
title: 'Undo Action',
message: 'File deleted successfully.',
type: ToastType.success,
position: ToastPosition.bottom,
style: ToastStyle.snackBar,
action: TextButton(
onPressed: () {
debugPrint('Undo pressed');
},
child: const Text('Undo', style: TextStyle(color: Colors.white)),
),
);
đŦ Without Title #
Toastify.show(
context,
message: 'Settings have been updated.',
type: ToastType.info,
position: ToastPosition.bottom,
style: ToastStyle.snackBar,
);
đ With onDismiss Callback #
Toastify.show(
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,
title: 'Upload File',
message: 'Uploading in progress...',
type: ToastType.info,
position: ToastPosition.bottom,
style: ToastStyle.snackBar,
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)),
),
);
đī¸ Animation Control Examples (v1.1.0) #
Smooth Fade Animation #
Toastify.show(
context,
title: "Smooth Animation",
message: "Custom fade-in and fade-out animation.",
type: ToastType.success,
appearCurve: Curves.easeOut,
dismissCurve: Curves.easeIn,
animationDuration: const Duration(milliseconds: 300),
);
Bounce-In Entrance #
Toastify.show(
context,
title: "Bounce In",
message: "This toast uses a bounce entrance.",
type: ToastType.info,
appearCurve: Curves.bounceOut,
dismissCurve: Curves.easeInExpo,
animationDuration: const Duration(milliseconds: 450),
);
â¤ī¸ Author #
Created by Thant Zin
- GitHub Home: https://github.com/tz-thantzin
- Repository: https://github.com/tz-thantzin/my_toastify
Copyright (Šī¸) 2025 Thant Zin