ntoaster 1.0.0
ntoaster: ^1.0.0 copied to clipboard
A Notification Toaster that toasts notifications.
NToaster #
Notification Toaster.
Toasts are lightweight notifications designed to mimic the push notifications that have been popularized by mobile and desktop operating systems.
Features #
- Use either a Singleton or an InheritedWidget to get access to the Notifications Center.
- Completely flexible animation and widget UI.
- You can remove the notification programmatically.
- When the user long presses the notification its timer is paused until it is free.
Usage #
- Attach the notification center manually using the
NToasterController.attach
or Construct aNToasterCenter
which takes care of attaching and detaching the notification center and provides you with anNToaster
InheritedWidget
.
// Manual attachment
final ntoaster = NToasterController.getInstance();
ntoaster.attach(context, configuration: NToasterConfiguration
(
)) // Pass your center level configuration;
copied to clipboard
// Widget attachment
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const NToasterCenter(
child: MyHomePage(title: 'Flutter Demo Home Page')),
);
}
copied to clipboard
- Enqueue your notifications (with whichever size/animation)
// with `InheritedWidget`
final ntoaster = NToaster.of(context);
NotificationMetaData? notification;
notification = NotificationMetaData(
showFor: Duration(milliseconds:5000),
item: GestureDetector(
onTap: () {
notification?.remove();
},
child: SizedBox(
height:100,
width: 300,
child: Card(
elevation: 8.0,
color: Colors.green,child: Text("$_counter Cool title",style: Theme.of(context).textTheme.subtitle1?.copyWith(color: Colors.white),),),),),
);
ntoaster.enqueue(notification,);
copied to clipboard
- If you hold into a reference of a
NotificationMetaData
you candequeue
it immediately before the timer ends.
final notificationX = NotificationMetaData(...);
final ntoaster = NToaster.of(context);
ntoaster.dequeue(notificationX);
copied to clipboard