showNotification<T> function
OverlaySupportEntry
showNotification<T>({
- String? title,
- Widget? titleWidget,
- Widget? body,
- bool isSwipeDismissable = true,
- Duration? duration,
- bool? showDismissLink,
- Widget? leading,
- OverlaySupportBuilder? trailing,
- OverlaySupportCallback? onTap,
Implementation
OverlaySupportEntry showNotification<T>(
{String? title,
Widget? titleWidget,
Widget? body,
bool isSwipeDismissable = true,
Duration? duration,
bool? showDismissLink,
Widget? leading,
OverlaySupportBuilder? trailing,
OverlaySupportCallback? onTap}) {
OverlaySupportEntry? entry;
entry = showOverlayNotification(
(context) {
final overlay = context.themes.platformOverlayTheme;
final child = Material(
elevation: overlay.elevation,
child: ListTileTheme(
style: ListTileStyle.list,
textColor: overlay.foregroundColor,
iconColor: overlay.foregroundColor,
dense: false,
child: Container(
color: overlay.backgroundColor,
child: SafeArea(
bottom: false,
child: ListTile(
title: titleWidget ?? Text(title ?? "Notification"),
onTap: () {
onTap?.call(context, entry);
},
contentPadding: overlay.padding,
subtitle: body,
leading: leading,
trailing: trailing?.call(context, () => entry) ??
(showDismissLink == true
? SunnyNotificationDismissLink(entry: () => entry!)
: null)),
)),
),
);
return isSwipeDismissable
? Dismissible(
direction: DismissDirection.up,
onDismissed: (_) {
entry?.dismiss(animate: false);
},
child: child,
key: Key("overlay-${i++}"),
)
: child;
},
duration: duration ?? 0.seconds,
);
return entry;
}