diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart index 9912e638222..1ca0956cd6e 100644 --- a/sdk/lib/html/dart2js/html_dart2js.dart +++ b/sdk/lib/html/dart2js/html_dart2js.dart @@ -16966,8 +16966,8 @@ class Geolocation extends JavaScriptObject { new StreamController( sync: true, onCancel: () { - assert(watchId != null); - _clearWatch(watchId!); + final id = watchId; + if (id != null) _clearWatch(id); }); controller.onListen = () { assert(watchId == null); diff --git a/tools/dom/templates/html/impl/impl_Geolocation.darttemplate b/tools/dom/templates/html/impl/impl_Geolocation.darttemplate index db6fbbf5c4b..bee8d856487 100644 --- a/tools/dom/templates/html/impl/impl_Geolocation.darttemplate +++ b/tools/dom/templates/html/impl/impl_Geolocation.darttemplate @@ -52,8 +52,8 @@ $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS StreamController controller = new StreamController(sync: true, onCancel: () { - assert(watchId != null); - _clearWatch(watchId$NULLASSERT); + final id = watchId; + if (id != null) _clearWatch(id); } ); controller.onListen = () {