Committed by
GitHub
Migrate platform_interface to pigeon 0.2.1 (#113)
* Migrate platform_interface to pigeon 0.2.1 * Format * Fix Analysis
Showing
7 changed files
with
111 additions
and
77 deletions
| 1 | -// Autogenerated from Pigeon (v0.1.14), do not edit directly. | 1 | +// Autogenerated from Pigeon (v0.2.1), do not edit directly. |
| 2 | // See also: https://pub.dev/packages/pigeon | 2 | // See also: https://pub.dev/packages/pigeon |
| 3 | -// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import | 3 | +// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types |
| 4 | +// @dart = 2.12 | ||
| 4 | import 'dart:async'; | 5 | import 'dart:async'; |
| 5 | import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; | 6 | import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; |
| 6 | 7 | ||
| 7 | import 'package:flutter/services.dart'; | 8 | import 'package:flutter/services.dart'; |
| 8 | 9 | ||
| 9 | class ToggleMessage { | 10 | class ToggleMessage { |
| 10 | - late bool enable; | 11 | + bool? enable; |
| 11 | 12 | ||
| 12 | - // ignore: unused_element | ||
| 13 | - Map<dynamic, dynamic> _toMap() { | ||
| 14 | - final pigeonMap = <dynamic, dynamic>{}; | 13 | + Object encode() { |
| 14 | + final Map<Object?, Object?> pigeonMap = <Object?, Object?>{}; | ||
| 15 | pigeonMap['enable'] = enable; | 15 | pigeonMap['enable'] = enable; |
| 16 | return pigeonMap; | 16 | return pigeonMap; |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | - // ignore: unused_element | ||
| 20 | - static ToggleMessage _fromMap(Map<dynamic, dynamic> pigeonMap) { | ||
| 21 | - final result = ToggleMessage(); | ||
| 22 | - result.enable = pigeonMap['enable']; | ||
| 23 | - return result; | 19 | + static ToggleMessage decode(Object message) { |
| 20 | + final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>; | ||
| 21 | + return ToggleMessage()..enable = pigeonMap['enable'] as bool?; | ||
| 24 | } | 22 | } |
| 25 | } | 23 | } |
| 26 | 24 | ||
| 27 | class IsEnabledMessage { | 25 | class IsEnabledMessage { |
| 28 | - late bool enabled; | 26 | + bool? enabled; |
| 29 | 27 | ||
| 30 | - // ignore: unused_element | ||
| 31 | - Map<dynamic, dynamic> _toMap() { | ||
| 32 | - final pigeonMap = <dynamic, dynamic>{}; | 28 | + Object encode() { |
| 29 | + final Map<Object?, Object?> pigeonMap = <Object?, Object?>{}; | ||
| 33 | pigeonMap['enabled'] = enabled; | 30 | pigeonMap['enabled'] = enabled; |
| 34 | return pigeonMap; | 31 | return pigeonMap; |
| 35 | } | 32 | } |
| 36 | 33 | ||
| 37 | - // ignore: unused_element | ||
| 38 | - static IsEnabledMessage _fromMap(Map<dynamic, dynamic> pigeonMap) { | ||
| 39 | - final result = IsEnabledMessage(); | ||
| 40 | - result.enabled = pigeonMap['enabled']; | ||
| 41 | - return result; | 34 | + static IsEnabledMessage decode(Object message) { |
| 35 | + final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>; | ||
| 36 | + return IsEnabledMessage()..enabled = pigeonMap['enabled'] as bool?; | ||
| 42 | } | 37 | } |
| 43 | } | 38 | } |
| 44 | 39 | ||
| 45 | class WakelockApi { | 40 | class WakelockApi { |
| 46 | - Future<void> toggle(ToggleMessage arg) async { | ||
| 47 | - final requestMap = arg._toMap(); | ||
| 48 | - const channel = BasicMessageChannel<dynamic>( | ||
| 49 | - 'dev.flutter.pigeon.WakelockApi.toggle', StandardMessageCodec()); | 41 | + /// Constructor for [WakelockApi]. The [binaryMessenger] named argument is |
| 42 | + /// available for dependency injection. If it is left null, the default | ||
| 43 | + /// BinaryMessenger will be used which routes to the host platform. | ||
| 44 | + WakelockApi({BinaryMessenger? binaryMessenger}) | ||
| 45 | + : _binaryMessenger = binaryMessenger; | ||
| 46 | + | ||
| 47 | + final BinaryMessenger? _binaryMessenger; | ||
| 50 | 48 | ||
| 51 | - final replyMap = await channel.send(requestMap); | 49 | + Future<void> toggle(ToggleMessage arg) async { |
| 50 | + final Object encoded = arg.encode(); | ||
| 51 | + final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( | ||
| 52 | + 'dev.flutter.pigeon.WakelockApi.toggle', const StandardMessageCodec(), | ||
| 53 | + binaryMessenger: _binaryMessenger); | ||
| 54 | + final Map<Object?, Object?>? replyMap = | ||
| 55 | + await channel.send(encoded) as Map<Object?, Object?>?; | ||
| 52 | if (replyMap == null) { | 56 | if (replyMap == null) { |
| 53 | throw PlatformException( | 57 | throw PlatformException( |
| 54 | code: 'channel-error', | 58 | code: 'channel-error', |
| 55 | message: 'Unable to establish connection on channel.', | 59 | message: 'Unable to establish connection on channel.', |
| 56 | - details: null); | 60 | + details: null, |
| 61 | + ); | ||
| 57 | } else if (replyMap['error'] != null) { | 62 | } else if (replyMap['error'] != null) { |
| 58 | - final error = replyMap['error']; | 63 | + final Map<Object?, Object?> error = |
| 64 | + (replyMap['error'] as Map<Object?, Object?>?)!; | ||
| 59 | throw PlatformException( | 65 | throw PlatformException( |
| 60 | - code: error['code'], | ||
| 61 | - message: error['message'], | ||
| 62 | - details: error['details']); | 66 | + code: (error['code'] as String?)!, |
| 67 | + message: error['message'] as String?, | ||
| 68 | + details: error['details'], | ||
| 69 | + ); | ||
| 63 | } else { | 70 | } else { |
| 64 | // noop | 71 | // noop |
| 65 | } | 72 | } |
| 66 | } | 73 | } |
| 67 | 74 | ||
| 68 | Future<IsEnabledMessage> isEnabled() async { | 75 | Future<IsEnabledMessage> isEnabled() async { |
| 69 | - const channel = BasicMessageChannel<dynamic>( | ||
| 70 | - 'dev.flutter.pigeon.WakelockApi.isEnabled', StandardMessageCodec()); | ||
| 71 | - | ||
| 72 | - final replyMap = await channel.send(null); | 76 | + final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( |
| 77 | + 'dev.flutter.pigeon.WakelockApi.isEnabled', | ||
| 78 | + const StandardMessageCodec(), | ||
| 79 | + binaryMessenger: _binaryMessenger); | ||
| 80 | + final Map<Object?, Object?>? replyMap = | ||
| 81 | + await channel.send(null) as Map<Object?, Object?>?; | ||
| 73 | if (replyMap == null) { | 82 | if (replyMap == null) { |
| 74 | throw PlatformException( | 83 | throw PlatformException( |
| 75 | code: 'channel-error', | 84 | code: 'channel-error', |
| 76 | message: 'Unable to establish connection on channel.', | 85 | message: 'Unable to establish connection on channel.', |
| 77 | - details: null); | 86 | + details: null, |
| 87 | + ); | ||
| 78 | } else if (replyMap['error'] != null) { | 88 | } else if (replyMap['error'] != null) { |
| 79 | - final error = replyMap['error']; | 89 | + final Map<Object?, Object?> error = |
| 90 | + (replyMap['error'] as Map<Object?, Object?>?)!; | ||
| 80 | throw PlatformException( | 91 | throw PlatformException( |
| 81 | - code: error['code'], | ||
| 82 | - message: error['message'], | ||
| 83 | - details: error['details']); | 92 | + code: (error['code'] as String?)!, |
| 93 | + message: error['message'] as String?, | ||
| 94 | + details: error['details'], | ||
| 95 | + ); | ||
| 84 | } else { | 96 | } else { |
| 85 | - return IsEnabledMessage._fromMap(replyMap['result']); | ||
| 86 | - } | ||
| 87 | - } | ||
| 88 | -} | ||
| 89 | - | ||
| 90 | -abstract class TestWakelockApi { | ||
| 91 | - void toggle(ToggleMessage arg); | ||
| 92 | - | ||
| 93 | - IsEnabledMessage isEnabled(); | ||
| 94 | - | ||
| 95 | - static void setup(TestWakelockApi? api) { | ||
| 96 | - { | ||
| 97 | - const channel = BasicMessageChannel<dynamic>( | ||
| 98 | - 'dev.flutter.pigeon.WakelockApi.toggle', StandardMessageCodec()); | ||
| 99 | - if (api == null) { | ||
| 100 | - channel.setMockMessageHandler(null); | ||
| 101 | - } else { | ||
| 102 | - channel.setMockMessageHandler((dynamic message) async { | ||
| 103 | - final mapMessage = message as Map<dynamic, dynamic>; | ||
| 104 | - final input = ToggleMessage._fromMap(mapMessage); | ||
| 105 | - api.toggle(input); | ||
| 106 | - return <dynamic, dynamic>{}; | ||
| 107 | - }); | ||
| 108 | - } | ||
| 109 | - } | ||
| 110 | - { | ||
| 111 | - const channel = BasicMessageChannel<dynamic>( | ||
| 112 | - 'dev.flutter.pigeon.WakelockApi.isEnabled', StandardMessageCodec()); | ||
| 113 | - if (api == null) { | ||
| 114 | - channel.setMockMessageHandler(null); | ||
| 115 | - } else { | ||
| 116 | - channel.setMockMessageHandler((dynamic message) async { | ||
| 117 | - final output = api.isEnabled(); | ||
| 118 | - return <dynamic, dynamic>{'result': output._toMap()}; | ||
| 119 | - }); | ||
| 120 | - } | 97 | + return IsEnabledMessage.decode(replyMap['result']!); |
| 121 | } | 98 | } |
| 122 | } | 99 | } |
| 123 | } | 100 | } |
| @@ -9,7 +9,7 @@ class MethodChannelWakelock extends WakelockPlatformInterface { | @@ -9,7 +9,7 @@ class MethodChannelWakelock extends WakelockPlatformInterface { | ||
| 9 | Future<bool> get enabled async { | 9 | Future<bool> get enabled async { |
| 10 | final message = await _api.isEnabled(); | 10 | final message = await _api.isEnabled(); |
| 11 | 11 | ||
| 12 | - return message.enabled; | 12 | + return message.enabled!; |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | @override | 15 | @override |
| @@ -2,7 +2,7 @@ name: wakelock_platform_interface | @@ -2,7 +2,7 @@ name: wakelock_platform_interface | ||
| 2 | description: >-2 | 2 | description: >-2 |
| 3 | A common platform interface for the wakelock plugin used by the different platform | 3 | A common platform interface for the wakelock plugin used by the different platform |
| 4 | implementations. | 4 | implementations. |
| 5 | -version: 0.2.0 | 5 | +version: 0.2.1 |
| 6 | homepage: >-2 | 6 | homepage: >-2 |
| 7 | https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_platform_interface | 7 | https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_platform_interface |
| 8 | 8 |
| 1 | +// Autogenerated from Pigeon (v0.2.1), do not edit directly. | ||
| 2 | +// See also: https://pub.dev/packages/pigeon | ||
| 3 | +// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import | ||
| 4 | +// @dart = 2.12 | ||
| 5 | +import 'dart:async'; | ||
| 6 | +import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; | ||
| 7 | +import 'package:flutter/services.dart'; | ||
| 8 | +import 'package:flutter_test/flutter_test.dart'; | ||
| 9 | + | ||
| 10 | +import 'package:wakelock_platform_interface/messages.dart'; | ||
| 11 | + | ||
| 12 | +abstract class TestWakelockApi { | ||
| 13 | + void toggle(ToggleMessage arg); | ||
| 14 | + IsEnabledMessage isEnabled(); | ||
| 15 | + static void setup(TestWakelockApi? api) { | ||
| 16 | + { | ||
| 17 | + const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( | ||
| 18 | + 'dev.flutter.pigeon.WakelockApi.toggle', StandardMessageCodec()); | ||
| 19 | + if (api == null) { | ||
| 20 | + channel.setMockMessageHandler(null); | ||
| 21 | + } else { | ||
| 22 | + channel.setMockMessageHandler((Object? message) async { | ||
| 23 | + assert(message != null, | ||
| 24 | + 'Argument for dev.flutter.pigeon.WakelockApi.toggle was null. Expected ToggleMessage.'); | ||
| 25 | + final ToggleMessage input = ToggleMessage.decode(message!); | ||
| 26 | + api.toggle(input); | ||
| 27 | + return <Object?, Object?>{}; | ||
| 28 | + }); | ||
| 29 | + } | ||
| 30 | + } | ||
| 31 | + { | ||
| 32 | + const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( | ||
| 33 | + 'dev.flutter.pigeon.WakelockApi.isEnabled', StandardMessageCodec()); | ||
| 34 | + if (api == null) { | ||
| 35 | + channel.setMockMessageHandler(null); | ||
| 36 | + } else { | ||
| 37 | + channel.setMockMessageHandler((Object? message) async { | ||
| 38 | + // ignore message | ||
| 39 | + final IsEnabledMessage output = api.isEnabled(); | ||
| 40 | + return <Object?, Object?>{'result': output.encode()}; | ||
| 41 | + }); | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | +} |
| @@ -3,6 +3,8 @@ import 'package:wakelock_platform_interface/messages.dart'; | @@ -3,6 +3,8 @@ import 'package:wakelock_platform_interface/messages.dart'; | ||
| 3 | import 'package:wakelock_platform_interface/method_channel_wakelock.dart'; | 3 | import 'package:wakelock_platform_interface/method_channel_wakelock.dart'; |
| 4 | import 'package:wakelock_platform_interface/wakelock_platform_interface.dart'; | 4 | import 'package:wakelock_platform_interface/wakelock_platform_interface.dart'; |
| 5 | 5 | ||
| 6 | +import 'messages.dart'; | ||
| 7 | + | ||
| 6 | class _ApiLogger implements TestWakelockApi { | 8 | class _ApiLogger implements TestWakelockApi { |
| 7 | final List<String> log = []; | 9 | final List<String> log = []; |
| 8 | late ToggleMessage toggleMessage; | 10 | late ToggleMessage toggleMessage; |
-
Please register or login to post a comment