service_worker.window library


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.
The parameter passed into the onnotificationclick handler, the NotificationEvent interface represents a notification click event that is dispatched on the ServiceWorkerGlobalScope of a ServiceWorker.
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.
The PushSubscription interface provides a subcription's URL endpoint and subscription ID.
Object containing optional subscribe parameters.
Represents a service worker. Multiple browsing contexts (e.g. pages, workers, etc.) can be associated with the same ServiceWorker object.
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.
Represents a service worker registration.


controller ServiceWorker
Returns a ServiceWorker object if its state is activated (the same object returned by This property returns null if the request is a force refresh (Shift + refresh) or if there is no active worker.
isNotSupported → bool
Whether ServiceWorker is not supported in the current browser.
isSupported → bool
Whether ServiceWorker is supported in the current browser.
onControllerChange → Stream<Event>
An event handler fired whenever a controllerchange event occurs — when the document's associated ServiceWorkerRegistration acquires a new worker.
onError → Stream<ErrorEvent>
An event handler fired whenever an error event occurs in the associated service workers.
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.)
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 worker.
serviceWorker ServiceWorkerContainer
API entry point for web apps (window.navigator.serviceWorker). Deprecated, use top-level fields and methods instead.


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.