professional_toast 1.0.2
professional_toast: ^1.0.2 copied to clipboard
A highly customizable, animated toast/snackbar-style notification package for Flutter with support for icons, colors, positions, stacking, actions, progress bars, RTL, and queuing.
import 'package:flutter/material.dart';
import 'package:professional_toast/professional_toast.dart';
void main() => runApp(const DemoApp());
class DemoApp extends StatelessWidget {
const DemoApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
builder: (context, child) {
// Wire up ProfessionalToast once, globally.
ProfessionalToast.init(context);
return child!;
},
home: const DemoPage(),
);
}
}
class DemoPage extends StatelessWidget {
const DemoPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Professional Toast Demo')),
body: Center(
child: Wrap(
spacing: 12,
runSpacing: 12,
children: [
ElevatedButton(
onPressed: () => ProfessionalToast.success(
'Profile updated successfully',
title: 'Success',
),
child: const Text('Success'),
),
ElevatedButton(
onPressed: () => ProfessionalToast.error(
'Could not connect to server',
title: 'Error',
),
child: const Text('Error'),
),
ElevatedButton(
onPressed: () => ProfessionalToast.warning('Low battery'),
child: const Text('Warning'),
),
ElevatedButton(
onPressed: () => ProfessionalToast.info('New update available'),
child: const Text('Info'),
),
ElevatedButton(
onPressed: () => ProfessionalToast.show(
'Item removed from cart',
icon: Icons.delete,
backgroundColor: Colors.black87,
position: ToastPosition.top,
animation: ToastAnimation.scale,
showProgressBar: true,
showCloseIcon: true,
actionLabel: 'UNDO',
onActionPressed: () => debugPrint('Undo pressed'),
),
child: const Text('Fully Custom'),
),
ElevatedButton(
onPressed: () {
// Default behavior: these stack on top of each other,
// each counting down independently.
ProfessionalToast.show('First message');
ProfessionalToast.show('Second message');
ProfessionalToast.show('Third message');
},
child: const Text('Stacking Demo'),
),
ElevatedButton(
onPressed: () {
// queue: true forces strictly sequential playback instead.
ProfessionalToast.show('First (queued)', queue: true);
ProfessionalToast.show('Second (queued)', queue: true);
ProfessionalToast.show('Third (queued)', queue: true);
},
child: const Text('Queue Demo'),
),
ElevatedButton(
onPressed: () => ProfessionalToast.show(
'مرحبا، تم الحفظ بنجاح', // "Hello, saved successfully"
type: ToastType.success,
textDirection: TextDirection.rtl,
),
child: const Text('RTL Demo'),
),
],
),
),
);
}
}