From ac297191325e23269291fe95d8877869550e13c3 Mon Sep 17 00:00:00 2001 From: yuoohama <50433979+negotoyolo@users.noreply.github.com> Date: Thu, 27 Apr 2023 16:55:25 +0900 Subject: [PATCH 1/3] Change setMockMethodCallHandler. --- .../test/federated_plugin_test.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/experimental/federated_plugin/federated_plugin/test/federated_plugin_test.dart b/experimental/federated_plugin/federated_plugin/test/federated_plugin_test.dart index eba62999b3d..af9625ec024 100644 --- a/experimental/federated_plugin/federated_plugin/test/federated_plugin_test.dart +++ b/experimental/federated_plugin/federated_plugin/test/federated_plugin_test.dart @@ -11,11 +11,16 @@ void main() { group('Federated Plugin Test', () { const batteryLevel = 34; - const MethodChannel('battery').setMockMethodCallHandler((call) async { - if (call.method == 'getBatteryLevel') { - return batteryLevel; - } - }); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler( + const MethodChannel('battery'), + (message) async { + if (message.method == 'getBatteryLevel') { + return batteryLevel; + } + return null; + }, + ); test('getBatteryLevel method test', () async { final result = await getBatteryLevel(); From 6e6c9d5d088145b4d222553e5048efca95695d12 Mon Sep 17 00:00:00 2001 From: yuoohama <50433979+negotoyolo@users.noreply.github.com> Date: Thu, 27 Apr 2023 17:12:26 +0900 Subject: [PATCH 2/3] Update widget_test.dart --- .../example/test/widget_test.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/experimental/federated_plugin/federated_plugin/example/test/widget_test.dart b/experimental/federated_plugin/federated_plugin/example/test/widget_test.dart index e0f5b568fa8..ef1ac7d424a 100644 --- a/experimental/federated_plugin/federated_plugin/example/test/widget_test.dart +++ b/experimental/federated_plugin/federated_plugin/example/test/widget_test.dart @@ -11,11 +11,16 @@ void main() { group('federated plugin demo tests', () { const batteryLevel = 45; setUpAll(() { - const MethodChannel('battery').setMockMethodCallHandler((call) async { - if (call.method == 'getBatteryLevel') { - return batteryLevel; - } - }); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler( + const MethodChannel('battery'), + (message) async { + if (message.method == 'getBatteryLevel') { + return batteryLevel; + } + return null; + }, + ); }); testWidgets('get current battery level from platform', (tester) async { From 1637a13fe10c5fc284b3953f10dc5f5d6de56d9b Mon Sep 17 00:00:00 2001 From: yuoohama <50433979+negotoyolo@users.noreply.github.com> Date: Thu, 27 Apr 2023 20:38:22 +0900 Subject: [PATCH 3/3] Update federated_plugin_platform_interface_test.dart --- .../federated_plugin_platform_interface_test.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/experimental/federated_plugin/federated_plugin_platform_interface/test/federated_plugin_platform_interface_test.dart b/experimental/federated_plugin/federated_plugin_platform_interface/test/federated_plugin_platform_interface_test.dart index 5b0f561eabb..ea281c5cf96 100644 --- a/experimental/federated_plugin/federated_plugin_platform_interface/test/federated_plugin_platform_interface_test.dart +++ b/experimental/federated_plugin/federated_plugin_platform_interface/test/federated_plugin_platform_interface_test.dart @@ -11,11 +11,16 @@ void main() { group('MethodChannel test', () { const batteryLevel = 89; - const MethodChannel('battery').setMockMethodCallHandler((call) async { - if (call.method == 'getBatteryLevel') { - return batteryLevel; - } - }); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler( + const MethodChannel('battery'), + (message) async { + if (message.method == 'getBatteryLevel') { + return batteryLevel; + } + return null; + }, + ); test('getBatteryLevel method test', () async { final locationMethodChannel = BatteryMethodChannel();