import 'notification_bridge_stub.dart' if (dart.library.js_interop) 'notification_bridge_web.dart' if (dart.library.io) 'notification_bridge_io.dart' as impl; import 'notification_models.dart'; /// Where the notification capability actually posts. /// /// The controller depends on this, not on any platform, so the dedupe, the /// permission rules and the content are all testable without a browser. A bridge /// answers the platform's real facts and never guesses: [environment] returns /// what the platform says (including "unsupported"), [requestPermission] is only /// called from an explicit gesture, and [show] reports whether the platform /// accepted the notification. abstract interface class NotificationBridge { /// The platform's own facts: support, secure context and permission word. NotificationEnvironment environment(); /// Asks the platform, from an explicit operator gesture, and returns its own /// answer word. Never a guess, and never called by the controller on its own. Future requestPermission(); /// Shows one notification, attaching [onTap] as its tap intent when given. /// Returns whether the platform accepted it. bool show(NotificationMessage message, {void Function()? onTap}); } /// The bridge for the current platform: the browser `Notification` on the web, /// an honest "unsupported" elsewhere. NotificationBridge createNotificationBridge() => impl.createNotificationBridge();