dart-lang / html

Dart port of html5lib. For parsing HTML/HTML5 with Dart. Works in the client and on the server.

Home Page:https://pub.dev/packages/html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PushManager.getSubscription() errors on null

mrwonko opened this issue · comments

PushManager.getSubscription is defined as Future<PushSubscription>, but if there's no subscription, it actually returns null, leading to an Error:

Error: Expected a value of type 'FutureOr', but got one of type 'Null'

According to https://developer.mozilla.org/en-US/docs/Web/API/PushManager/getSubscription, this is expected, and I don't see how else I'd check whether a subscription has been configured yet.

Can be reproduced with

await (await html.window.navigator.serviceWorker?.ready)?.pushManager?.getSubscription();