diff --git a/packages/flutter/lib/src/services/platform_channel.dart b/packages/flutter/lib/src/services/platform_channel.dart index bf2581faf2..2e12e495aa 100644 --- a/packages/flutter/lib/src/services/platform_channel.dart +++ b/packages/flutter/lib/src/services/platform_channel.dart @@ -67,7 +67,7 @@ class BasicMessageChannel { /// /// The handler's return value is sent back to the platform plugins as a /// message reply. It may be null. - void setMessageHandler(Future handler(T message)) { + void setMessageHandler(Future Function(T message)? handler) { if (handler == null) { binaryMessenger.setMessageHandler(name, null); } else { @@ -88,7 +88,7 @@ class BasicMessageChannel { /// /// This is intended for testing. Messages intercepted in this manner are not /// sent to platform plugins. - void setMockMessageHandler(Future handler(T message)) { + void setMockMessageHandler(Future Function(T message) handler) { if (handler == null) { binaryMessenger.setMockMessageHandler(name, null); } else { @@ -390,7 +390,7 @@ class MethodChannel { /// /// This method is useful for tests or test harnesses that want to assert the /// handler for the specified channel has not been altered by a previous test. - bool checkMethodCallHandler(Future handler(MethodCall call)) => _methodChannelHandlers[this] == handler; + bool checkMethodCallHandler(Future Function(MethodCall call)? handler) => _methodChannelHandlers[this] == handler; /// Sets a mock callback for intercepting method invocations on this channel. /// @@ -410,7 +410,7 @@ class MethodChannel { /// return value of the call. The value will be encoded using /// [MethodCodec.encodeSuccessEnvelope], to act as if platform plugin had /// returned that value. - void setMockMethodCallHandler(Future handler(MethodCall call)) { + void setMockMethodCallHandler(Future Function(MethodCall call)? handler) { _methodChannelMockHandlers[this] = handler; binaryMessenger.setMockMessageHandler( name, @@ -423,7 +423,7 @@ class MethodChannel { /// /// This method is useful for tests or test harnesses that want to assert the /// handler for the specified channel has not been altered by a previous test. - bool checkMockMethodCallHandler(Future handler(MethodCall call)) => _methodChannelMockHandlers[this] == handler; + bool checkMockMethodCallHandler(Future Function(MethodCall call)? handler) => _methodChannelMockHandlers[this] == handler; Future _handleAsMethodCall(ByteData? message, Future handler(MethodCall call)) async { final MethodCall call = codec.decodeMethodCall(message);