Return null instead of throwing if an instance method is passed to PluginUtilities.getCallbackHandle (flutter/engine#6260)
This commit is contained in:
@@ -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<Function, CallbackHandle> _forwardCache =
|
||||
<Function, CallbackHandle>{};
|
||||
static Map<CallbackHandle, Function> _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
|
||||
|
||||
Reference in New Issue
Block a user