diff --git a/engine/src/flutter/lib/ui/plugins.dart b/engine/src/flutter/lib/ui/plugins.dart index a54ba041e8..c3a64d0ba4 100644 --- a/engine/src/flutter/lib/ui/plugins.dart +++ b/engine/src/flutter/lib/ui/plugins.dart @@ -16,11 +16,11 @@ class CallbackHandle { CallbackHandle.fromRawHandle(this._handle) : assert(_handle != null, "'_handle' must not be null."); - final int _handle; + final int/*!*/ _handle; /// Get the raw callback handle to pass over a [MethodChannel] or [SendPort] /// (to pass to another [Isolate]). - int toRawHandle() => _handle; + int/*!*/ toRawHandle() => _handle; @override bool operator ==(dynamic other) { @@ -43,12 +43,12 @@ class CallbackHandle { class PluginUtilities { // This class is only a namespace, and should not be instantiated or // extended directly. - factory PluginUtilities._() => null; + factory PluginUtilities._() => throw UnsupportedError('Namespace'); - static Map _forwardCache = - {}; - static Map _backwardCache = - {}; + static Map/*!*/ _forwardCache = + {}; + static Map/*!*/ _backwardCache = + {}; /// Get a handle to a named top-level or static callback function which can /// be easily passed between isolates. @@ -59,10 +59,10 @@ class PluginUtilities { /// [PluginUtilities.getCallbackFromHandle] to retrieve a tear-off of the /// original callback. If `callback` is not a top-level or static function, /// null is returned. - static CallbackHandle getCallbackHandle(Function callback) { + static CallbackHandle/*?*/ getCallbackHandle(Function/*!*/ callback) { assert(callback != null, "'callback' must not be null."); return _forwardCache.putIfAbsent(callback, () { - final int handle = _getCallbackHandle(callback); + final int/*?*/ handle = _getCallbackHandle(callback); return handle != null ? CallbackHandle.fromRawHandle(handle) : null; }); } @@ -75,7 +75,7 @@ class PluginUtilities { /// If `handle` is not a valid handle returned by /// [PluginUtilities.getCallbackHandle], null is returned. Otherwise, a /// tear-off of the callback associated with `handle` is returned. - static Function getCallbackFromHandle(CallbackHandle handle) { + static Function/*?*/ getCallbackFromHandle(CallbackHandle/*!*/ handle) { assert(handle != null, "'handle' must not be null."); return _backwardCache.putIfAbsent( handle, () => _getCallbackFromHandle(handle.toRawHandle())); diff --git a/engine/src/flutter/lib/web_ui/lib/src/ui/window.dart b/engine/src/flutter/lib/web_ui/lib/src/ui/window.dart index ae12047c66..c46efc466f 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/ui/window.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/ui/window.dart @@ -1062,11 +1062,12 @@ enum Brightness { // Unimplemented classes. // TODO(flutter_web): see https://github.com/flutter/flutter/issues/33614. class CallbackHandle { - CallbackHandle.fromRawHandle(this._handle); + CallbackHandle.fromRawHandle(this._handle) + : assert(_handle != null, "'_handle' must not be null."); - final int _handle; + final int/*!*/ _handle; - int toRawHandle() => _handle; + int/*!*/ toRawHandle() => _handle; @override bool operator ==(Object other) => identical(this, other); @@ -1077,11 +1078,15 @@ class CallbackHandle { // TODO(flutter_web): see https://github.com/flutter/flutter/issues/33615. class PluginUtilities { - static CallbackHandle getCallbackHandle(Function callback) { + // This class is only a namespace, and should not be instantiated or + // extended directly. + factory PluginUtilities._() => throw UnsupportedError('Namespace'); + + static CallbackHandle/*?*/ getCallbackHandle(Function callback) { throw UnimplementedError(); } - static Function getCallbackFromHandle(CallbackHandle handle) { + static Function/*?*/ getCallbackFromHandle(CallbackHandle handle) { throw UnimplementedError(); } }