This repository has been archived by the owner on Jul 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate platform_interface to pigeon 0.2.1 (#113)
* Migrate platform_interface to pigeon 0.2.1 * Format * Fix Analysis
- Loading branch information
1 parent
db843e4
commit 5c4906a
Showing
7 changed files
with
115 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
include: ../analysis_options.yaml | ||
|
||
analyzer: | ||
exclude: | ||
- 'lib/messages.dart' | ||
- 'test/messages.dart' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,123 +1,100 @@ | ||
// Autogenerated from Pigeon (v0.1.14), do not edit directly. | ||
// Autogenerated from Pigeon (v0.2.1), do not edit directly. | ||
// See also: https://pub.dev/packages/pigeon | ||
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import | ||
// 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 | ||
// @dart = 2.12 | ||
import 'dart:async'; | ||
import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; | ||
|
||
import 'package:flutter/services.dart'; | ||
|
||
class ToggleMessage { | ||
late bool enable; | ||
bool? enable; | ||
|
||
// ignore: unused_element | ||
Map<dynamic, dynamic> _toMap() { | ||
final pigeonMap = <dynamic, dynamic>{}; | ||
Object encode() { | ||
final Map<Object?, Object?> pigeonMap = <Object?, Object?>{}; | ||
pigeonMap['enable'] = enable; | ||
return pigeonMap; | ||
} | ||
|
||
// ignore: unused_element | ||
static ToggleMessage _fromMap(Map<dynamic, dynamic> pigeonMap) { | ||
final result = ToggleMessage(); | ||
result.enable = pigeonMap['enable']; | ||
return result; | ||
static ToggleMessage decode(Object message) { | ||
final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>; | ||
return ToggleMessage()..enable = pigeonMap['enable'] as bool?; | ||
} | ||
} | ||
|
||
class IsEnabledMessage { | ||
late bool enabled; | ||
bool? enabled; | ||
|
||
// ignore: unused_element | ||
Map<dynamic, dynamic> _toMap() { | ||
final pigeonMap = <dynamic, dynamic>{}; | ||
Object encode() { | ||
final Map<Object?, Object?> pigeonMap = <Object?, Object?>{}; | ||
pigeonMap['enabled'] = enabled; | ||
return pigeonMap; | ||
} | ||
|
||
// ignore: unused_element | ||
static IsEnabledMessage _fromMap(Map<dynamic, dynamic> pigeonMap) { | ||
final result = IsEnabledMessage(); | ||
result.enabled = pigeonMap['enabled']; | ||
return result; | ||
static IsEnabledMessage decode(Object message) { | ||
final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>; | ||
return IsEnabledMessage()..enabled = pigeonMap['enabled'] as bool?; | ||
} | ||
} | ||
|
||
class WakelockApi { | ||
Future<void> toggle(ToggleMessage arg) async { | ||
final requestMap = arg._toMap(); | ||
const channel = BasicMessageChannel<dynamic>( | ||
'dev.flutter.pigeon.WakelockApi.toggle', StandardMessageCodec()); | ||
/// Constructor for [WakelockApi]. The [binaryMessenger] named argument is | ||
/// available for dependency injection. If it is left null, the default | ||
/// BinaryMessenger will be used which routes to the host platform. | ||
WakelockApi({BinaryMessenger? binaryMessenger}) | ||
: _binaryMessenger = binaryMessenger; | ||
|
||
final BinaryMessenger? _binaryMessenger; | ||
|
||
final replyMap = await channel.send(requestMap); | ||
Future<void> toggle(ToggleMessage arg) async { | ||
final Object encoded = arg.encode(); | ||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( | ||
'dev.flutter.pigeon.WakelockApi.toggle', const StandardMessageCodec(), | ||
binaryMessenger: _binaryMessenger); | ||
final Map<Object?, Object?>? replyMap = | ||
await channel.send(encoded) as Map<Object?, Object?>?; | ||
if (replyMap == null) { | ||
throw PlatformException( | ||
code: 'channel-error', | ||
message: 'Unable to establish connection on channel.', | ||
details: null); | ||
code: 'channel-error', | ||
message: 'Unable to establish connection on channel.', | ||
details: null, | ||
); | ||
} else if (replyMap['error'] != null) { | ||
final error = replyMap['error']; | ||
final Map<Object?, Object?> error = | ||
(replyMap['error'] as Map<Object?, Object?>?)!; | ||
throw PlatformException( | ||
code: error['code'], | ||
message: error['message'], | ||
details: error['details']); | ||
code: (error['code'] as String?)!, | ||
message: error['message'] as String?, | ||
details: error['details'], | ||
); | ||
} else { | ||
// noop | ||
} | ||
} | ||
|
||
Future<IsEnabledMessage> isEnabled() async { | ||
const channel = BasicMessageChannel<dynamic>( | ||
'dev.flutter.pigeon.WakelockApi.isEnabled', StandardMessageCodec()); | ||
|
||
final replyMap = await channel.send(null); | ||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( | ||
'dev.flutter.pigeon.WakelockApi.isEnabled', | ||
const StandardMessageCodec(), | ||
binaryMessenger: _binaryMessenger); | ||
final Map<Object?, Object?>? replyMap = | ||
await channel.send(null) as Map<Object?, Object?>?; | ||
if (replyMap == null) { | ||
throw PlatformException( | ||
code: 'channel-error', | ||
message: 'Unable to establish connection on channel.', | ||
details: null); | ||
code: 'channel-error', | ||
message: 'Unable to establish connection on channel.', | ||
details: null, | ||
); | ||
} else if (replyMap['error'] != null) { | ||
final error = replyMap['error']; | ||
final Map<Object?, Object?> error = | ||
(replyMap['error'] as Map<Object?, Object?>?)!; | ||
throw PlatformException( | ||
code: error['code'], | ||
message: error['message'], | ||
details: error['details']); | ||
code: (error['code'] as String?)!, | ||
message: error['message'] as String?, | ||
details: error['details'], | ||
); | ||
} else { | ||
return IsEnabledMessage._fromMap(replyMap['result']); | ||
} | ||
} | ||
} | ||
|
||
abstract class TestWakelockApi { | ||
void toggle(ToggleMessage arg); | ||
|
||
IsEnabledMessage isEnabled(); | ||
|
||
static void setup(TestWakelockApi? api) { | ||
{ | ||
const channel = BasicMessageChannel<dynamic>( | ||
'dev.flutter.pigeon.WakelockApi.toggle', StandardMessageCodec()); | ||
if (api == null) { | ||
channel.setMockMessageHandler(null); | ||
} else { | ||
channel.setMockMessageHandler((dynamic message) async { | ||
final mapMessage = message as Map<dynamic, dynamic>; | ||
final input = ToggleMessage._fromMap(mapMessage); | ||
api.toggle(input); | ||
return <dynamic, dynamic>{}; | ||
}); | ||
} | ||
} | ||
{ | ||
const channel = BasicMessageChannel<dynamic>( | ||
'dev.flutter.pigeon.WakelockApi.isEnabled', StandardMessageCodec()); | ||
if (api == null) { | ||
channel.setMockMessageHandler(null); | ||
} else { | ||
channel.setMockMessageHandler((dynamic message) async { | ||
final output = api.isEnabled(); | ||
return <dynamic, dynamic>{'result': output._toMap()}; | ||
}); | ||
} | ||
return IsEnabledMessage.decode(replyMap['result']!); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Autogenerated from Pigeon (v0.2.1), do not edit directly. | ||
// See also: https://pub.dev/packages/pigeon | ||
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import | ||
// @dart = 2.12 | ||
import 'dart:async'; | ||
import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; | ||
import 'package:flutter/services.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import 'package:wakelock_platform_interface/messages.dart'; | ||
|
||
abstract class TestWakelockApi { | ||
void toggle(ToggleMessage arg); | ||
IsEnabledMessage isEnabled(); | ||
static void setup(TestWakelockApi? api) { | ||
{ | ||
const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( | ||
'dev.flutter.pigeon.WakelockApi.toggle', StandardMessageCodec()); | ||
if (api == null) { | ||
channel.setMockMessageHandler(null); | ||
} else { | ||
channel.setMockMessageHandler((Object? message) async { | ||
assert(message != null, | ||
'Argument for dev.flutter.pigeon.WakelockApi.toggle was null. Expected ToggleMessage.'); | ||
final ToggleMessage input = ToggleMessage.decode(message!); | ||
api.toggle(input); | ||
return <Object?, Object?>{}; | ||
}); | ||
} | ||
} | ||
{ | ||
const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( | ||
'dev.flutter.pigeon.WakelockApi.isEnabled', StandardMessageCodec()); | ||
if (api == null) { | ||
channel.setMockMessageHandler(null); | ||
} else { | ||
channel.setMockMessageHandler((Object? message) async { | ||
// ignore message | ||
final IsEnabledMessage output = api.isEnabled(); | ||
return <Object?, Object?>{'result': output.encode()}; | ||
}); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters