diff --git a/engine/src/flutter/lib/ui/plugins.dart b/engine/src/flutter/lib/ui/plugins.dart index 215c521247..0ae2b68ddb 100644 --- a/engine/src/flutter/lib/ui/plugins.dart +++ b/engine/src/flutter/lib/ui/plugins.dart @@ -32,7 +32,7 @@ abstract class PluginUtilities { // This class is only a namespace, and should not be instantiated or // extended directly. factory PluginUtilities._() => null; - + static Map _forwardCache = {}; static Map _backwardCache = @@ -49,8 +49,10 @@ abstract class PluginUtilities { /// null is returned. static CallbackHandle getCallbackHandle(Function callback) { assert(callback != null, "'callback' must not be null."); - return _forwardCache.putIfAbsent(callback, - () => new CallbackHandle.fromRawHandle(_getCallbackHandle(callback))); + return _forwardCache.putIfAbsent(callback, () { + final int handle = _getCallbackHandle(callback); + return handle != null ? new CallbackHandle.fromRawHandle(handle) : null; + }); } /// Get a tear-off of a named top-level or static callback represented by a