NotificationDropdown class

Bell icon dropdown with a real-time unread badge over a notification stream.

Uses WPopover for overlay mechanics and StreamBuilder for live unread counts.

Example

NotificationDropdown(
  notificationStream: Notify.notifications(),
  onMarkAsRead: (id) => Notify.markAsRead(id),
  onMarkAllAsRead: () => Notify.markAllAsRead(),
  onNotificationTap: (n) => MagicRoute.to(n.actionUrl ?? '/'),
  onViewAll: () => MagicRoute.to('/notifications'),
)

Restyling it

The defaults are Wind's own palette (bg-white, text-gray-500, bg-red-500), which reads as a foreign control next to an app whose other controls are written in that app's semantic aliases. Four surfaces take an override so an adopter can answer in its own vocabulary without forking the widget: triggerClassName, triggerIconClassName, badgeClassName with badgeTextClassName, and panelClassName.

Each override REPLACES its default outright, layout tokens included, rather than appending to it, so a value that changes one token still has to carry the rest:

NotificationDropdown(
  notificationStream: Notify.notifications(),
  triggerClassName: 'w-9 h-9 rounded-lg flex items-center justify-center '
      'bg-surface hover:bg-surface-container',
  triggerIconClassName: 'text-[18px] text-fg-muted',
  panelClassName: 'w-80 bg-surface border border-color-border rounded-xl',
)

Replacement rather than append is deliberate. Wind's last-wins is per family, and bg-* and dark:bg-* are two families, so an appended light-only override would leave the default's dark:bg-gray-800 alive and the adopter would be debugging a dark mode it never asked for.

Inheritance

Constructors

NotificationDropdown({Key? key, required Stream<List<DatabaseNotification>> notificationStream, Future<void> onMarkAsRead(String id)?, Future<void> onMarkAllAsRead()?, void onNotificationTap(DatabaseNotification notification)?, VoidCallback? onViewAll, String panelClassName = kNotificationDropdownPanelClassName, String triggerClassName = kNotificationDropdownTriggerClassName, String triggerIconClassName = kNotificationDropdownTriggerIconClassName, String badgeClassName = kNotificationDropdownBadgeClassName, String badgeTextClassName = kNotificationDropdownBadgeTextClassName})
Creates a NotificationDropdown.
const

Properties

badgeClassName → String
className of the unread badge pill, replacing kNotificationDropdownBadgeClassName.
final
badgeTextClassName → String
className of the unread count inside the badge pill, replacing kNotificationDropdownBadgeTextClassName.
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
notificationStream → Stream<List<DatabaseNotification>>
Stream of notifications to display.
final
onMarkAllAsRead → Future<void> Function()?
Callback when all notifications are marked as read.
final
onMarkAsRead → Future<void> Function(String id)?
Callback when a notification is marked as read.
final
onNotificationTap → void Function(DatabaseNotification notification)?
Callback when a notification is tapped.
final
onViewAll → VoidCallback?
Callback when the "View all" link is tapped.
final
panelClassName → String
className of the popover panel, replacing kNotificationDropdownPanelClassName.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
triggerClassName → String
className of the trigger surface, replacing kNotificationDropdownTriggerClassName.
final
triggerIconClassName → String
className of the trigger glyph, replacing kNotificationDropdownTriggerIconClassName.
final

Methods

build(BuildContext context) → Widget
Describes the part of the user interface represented by this widget.
override
createElement() → StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited