showSimpleNotification function
OverlaySupportEntry
showSimpleNotification(
- Widget content, {
- Widget? leading,
- Widget? subtitle,
- Widget? trailing,
- EdgeInsetsGeometry? contentPadding,
- Color? background,
- Color? foreground,
- double elevation = 16,
- Duration? duration,
- Key? key,
- bool autoDismiss = true,
- @Deprecated('use slideDismissDirection instead') bool slideDismiss = false,
- NotificationPosition position = NotificationPosition.top,
- BuildContext? context,
- DismissDirection? slideDismissDirection,
Show a simple notification above the top of window.
Implementation
OverlaySupportEntry showSimpleNotification(
Widget content, {
/**
* See more [ListTile.leading].
*/
Widget? leading,
/**
* See more [ListTile.subtitle].
*/
Widget? subtitle,
/**
* See more [ListTile.trailing].
*/
Widget? trailing,
/**
* See more [ListTile.contentPadding].
*/
EdgeInsetsGeometry? contentPadding,
/**
* The background color for notification, default to [ColorScheme.secondary].
*/
Color? background,
/**
* See more [ListTileTheme.textColor],[ListTileTheme.iconColor].
*/
Color? foreground,
/**
* The elevation of notification, see more [Material.elevation].
*/
double elevation = 16,
Duration? duration,
Key? key,
/**
* True to auto hide after duration [kNotificationDuration].
*/
bool autoDismiss = true,
/**
* Support left/right to dismiss notification.
*/
@Deprecated('use slideDismissDirection instead') bool slideDismiss = false,
/**
* The position of notification, default is [NotificationPosition.top],
*/
NotificationPosition position = NotificationPosition.top,
BuildContext? context,
/**
* The direction in which the notification can be dismissed.
*/
DismissDirection? slideDismissDirection,
}) {
final dismissDirection = slideDismissDirection ??
(slideDismiss ? DismissDirection.horizontal : DismissDirection.none);
final entry = showOverlayNotification(
(context) {
return SlideDismissible(
direction: dismissDirection,
key: ValueKey(key),
child: Material(
color: background ?? Theme.of(context).colorScheme.secondary,
elevation: elevation,
child: SafeArea(
bottom: position == NotificationPosition.bottom,
top: position == NotificationPosition.top,
child: ListTileTheme(
textColor:
foreground ?? Theme.of(context).colorScheme.onSecondary,
iconColor:
foreground ?? Theme.of(context).colorScheme.onSecondary,
child: ListTile(
leading: leading,
title: content,
subtitle: subtitle,
trailing: trailing,
contentPadding: contentPadding,
),
)),
),
);
},
duration: autoDismiss ? duration : Duration.zero,
key: key,
position: position,
context: context,
);
return entry;
}