null-annotate lib/ui/plugins.dart (#18353)
diff --git a/lib/ui/plugins.dart b/lib/ui/plugins.dart
index a54ba04..c3a64d0 100644
--- a/lib/ui/plugins.dart
+++ b/lib/ui/plugins.dart
@@ -16,11 +16,11 @@
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 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<Function, CallbackHandle> _forwardCache =
- <Function, CallbackHandle>{};
- static Map<CallbackHandle, Function> _backwardCache =
- <CallbackHandle, Function>{};
+ static Map<Function/*!*/, CallbackHandle/*?*/>/*!*/ _forwardCache =
+ <Function/*!*/, CallbackHandle/*?*/>{};
+ static Map<CallbackHandle/*!*/, Function/*?*/>/*!*/ _backwardCache =
+ <CallbackHandle/*!*/, Function/*?*/>{};
/// Get a handle to a named top-level or static callback function which can
/// be easily passed between isolates.
@@ -59,10 +59,10 @@
/// [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 @@
/// 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/lib/web_ui/lib/src/ui/window.dart b/lib/web_ui/lib/src/ui/window.dart
index ae12047..c46efc4 100644
--- a/lib/web_ui/lib/src/ui/window.dart
+++ b/lib/web_ui/lib/src/ui/window.dart
@@ -1062,11 +1062,12 @@
// 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 @@
// 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();
}
}