showSimpleNotification function

OverlaySupportEntry showSimpleNotification (
  1. Widget content,
  2. {Widget leading,
  3. Widget subtitle,
  4. Widget trailing,
  5. EdgeInsetsGeometry contentPadding,
  6. Color background,
  7. Color foreground,
  8. double elevation: 16,
  9. Key key,
  10. bool autoDismiss: true,
  11. bool slideDismiss: false,
  12. NotificationPosition position: NotificationPosition.top}
)

show a simple notification above the top of window

content see more ListTile.title leading see more ListTile.leading subtitle see more ListTile.subtitle trailing see more ListTile.trailing contentPadding see more ListTile.contentPadding

background the background color for notification , default is ThemeData.accentColor foreground see more ListTileTheme.textColor,ListTileTheme.iconColor

elevation the elevation of notification, see more Material.elevation autoDismiss true to auto hide after duration kNotificationDuration slideDismiss support left/right to dismiss notification position the position of notification, default is NotificationPosition.top, can be NotificationPosition.top or NotificationPosition.bottom

Implementation

OverlaySupportEntry showSimpleNotification(Widget content,
    {Widget leading,
    Widget subtitle,
    Widget trailing,
    EdgeInsetsGeometry contentPadding,
    Color background,
    Color foreground,
    double elevation = 16,
    Key key,
    bool autoDismiss = true,
    bool slideDismiss = false,
    NotificationPosition position = NotificationPosition.top}) {
  final entry = showOverlayNotification((context) {
    return SlideDismissible(
      enable: slideDismiss,
      key: ValueKey(key),
      child: Material(
        color: background ?? Theme.of(context)?.accentColor,
        elevation: elevation,
        child: SafeArea(
            bottom: position == NotificationPosition.bottom,
            top: position == NotificationPosition.top,
            child: ListTileTheme(
              textColor: foreground ?? Theme.of(context)?.accentTextTheme?.title?.color,
              iconColor: foreground ?? Theme.of(context)?.accentTextTheme?.title?.color,
              child: ListTile(
                leading: leading,
                title: content,
                subtitle: subtitle,
                trailing: trailing,
                contentPadding: contentPadding,
              ),
            )),
      ),
    );
  }, duration: autoDismiss ? null : Duration.zero, key: key, position: position);
  return entry;
}