window library

Classes

ErrorEvent
Event
ExtendableEvent
Extends the lifetime of the install and activate events dispatched on the ServiceWorkerGlobalScope as part of the service worker lifecycle. This ensures that any functional events (like FetchEvent) are not dispatched to the ServiceWorker until it upgrades database schemas, deletes outdated cache entries, etc.
MessageEvent
NotificationEvent
The parameter passed into the onnotificationclick handler, the NotificationEvent interface represents a notification click event that is dispatched on the ServiceWorkerGlobalScope of a ServiceWorker.
PushManager
The PushManager interface provides a way to receive notifications from third-party servers as well as request URLs for push notifications. This interface has replaced functionality offered by the obsolete PushRegistrationManager.
PushSubscription
The PushSubscription interface provides a subcription's URL endpoint and subscription ID.
PushSubscriptionOptions
Object containing optional subscribe parameters.
ServiceWorker
Represents a service worker. Multiple browsing contexts (e.g. pages, workers, etc.) can be associated with the same ServiceWorker object.
ServiceWorkerContainer
Provides an object representing the service worker as an overall unit in the network ecosystem, including facilities to register, unregister and update service workers, and access the state of service workers and their registrations.
ServiceWorkerRegisterOptions
ServiceWorkerRegistration
Represents a service worker registration.
ShowNotificationOptions

Properties

controller ServiceWorker?
Returns a ServiceWorker object if its state is activated (the same object returned by ServiceWorkerRegistration.active). This property returns null if the request is a force refresh (Shift + refresh) or if there is no active worker.
no setter
isNotSupported bool
Whether ServiceWorker is not supported in the current browser.
no setter
isSupported bool
Whether ServiceWorker is supported in the current browser.
no setter
onControllerChange Stream<Event>
An event handler fired whenever a controllerchange event occurs — when the document's associated ServiceWorkerRegistration acquires a new ServiceWorkerRegistration.active worker.
no setter
onError Stream<ErrorEvent>
An event handler fired whenever an error event occurs in the associated service workers.
no setter
onMessage Stream<MessageEvent>
An event handler fired whenever a message event occurs — when incoming messages are received to the ServiceWorkerContainer object (e.g. via a MessagePort.postMessage() call.)
no setter
ready Future<ServiceWorkerRegistration>
Defines whether a service worker is ready to control a page or not. It returns a Promise that will never reject, which resolves to a ServiceWorkerRegistration with an ServiceWorkerRegistration.active worker.
no setter
serviceWorker ServiceWorkerContainer?
API entry point for web apps (window.navigator.serviceWorker). Deprecated, use top-level fields and methods instead.
no setter

Functions

addEventListener<K>(String type, dynamic listener(K event), [bool? useCapture]) → void
Attach an event listener.
getRegistration([String? scope]) Future<ServiceWorkerRegistration>
Gets a ServiceWorkerRegistration object whose scope URL matches the provided document URL. If the method can't return a ServiceWorkerRegistration, it returns a Promise. scope URL of the registration object you want to return. This is usually a relative URL.
getRegistrations() Future<List<ServiceWorkerRegistration>>
Returns all ServiceWorkerRegistrations associated with a ServiceWorkerContainer in an array. If the method can't return ServiceWorkerRegistrations, it returns a Promise.
register(String scriptURL, [ServiceWorkerRegisterOptions? options]) Future<ServiceWorkerRegistration>
Creates or updates a ServiceWorkerRegistration for the given scriptURL. Currently available options are: scope: A USVString representing a URL that defines a service worker's registration scope; what range of URLs a service worker can control. This is usually a relative URL, and it defaults to '/' when not specified.