Skip to content

Commit

Permalink
Fixed dart formatting issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
diegotori committed Dec 21, 2024
1 parent 7a6b907 commit 8dd3673
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 33 deletions.
30 changes: 18 additions & 12 deletions wakelock_plus_platform_interface/lib/messages.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ PlatformException _createConnectionError(String channelName) {
);
}

List<Object?> wrapResponse({Object? result, PlatformException? error, bool empty = false}) {
List<Object?> wrapResponse(
{Object? result, PlatformException? error, bool empty = false}) {
if (empty) {
return <Object?>[];
}
Expand Down Expand Up @@ -69,18 +70,17 @@ class IsEnabledMessage {
}
}


class _PigeonCodec extends StandardMessageCodec {
const _PigeonCodec();
@override
void writeValue(WriteBuffer buffer, Object? value) {
if (value is int) {
buffer.putUint8(4);
buffer.putInt64(value);
} else if (value is ToggleMessage) {
} else if (value is ToggleMessage) {
buffer.putUint8(129);
writeValue(buffer, value.encode());
} else if (value is IsEnabledMessage) {
} else if (value is IsEnabledMessage) {
buffer.putUint8(130);
writeValue(buffer, value.encode());
} else {
Expand All @@ -91,9 +91,9 @@ class _PigeonCodec extends StandardMessageCodec {
@override
Object? readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
case 129:
case 129:
return ToggleMessage.decode(readValue(buffer)!);
case 130:
case 130:
return IsEnabledMessage.decode(readValue(buffer)!);
default:
return super.readValueOfType(type, buffer);
Expand All @@ -105,18 +105,22 @@ class WakelockPlusApi {
/// Constructor for [WakelockPlusApi]. 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.
WakelockPlusApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
WakelockPlusApi(
{BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
: pigeonVar_binaryMessenger = binaryMessenger,
pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
pigeonVar_messageChannelSuffix =
messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
final BinaryMessenger? pigeonVar_binaryMessenger;

static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();

final String pigeonVar_messageChannelSuffix;

Future<void> toggle(ToggleMessage msg) async {
final String pigeonVar_channelName = 'dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.toggle$pigeonVar_messageChannelSuffix';
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
final String pigeonVar_channelName =
'dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.toggle$pigeonVar_messageChannelSuffix';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
Expand All @@ -137,8 +141,10 @@ class WakelockPlusApi {
}

Future<IsEnabledMessage> isEnabled() async {
final String pigeonVar_channelName = 'dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.isEnabled$pigeonVar_messageChannelSuffix';
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
final String pigeonVar_channelName =
'dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.isEnabled$pigeonVar_messageChannelSuffix';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
Expand Down
61 changes: 40 additions & 21 deletions wakelock_plus_platform_interface/test/messages.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ import 'package:flutter_test/flutter_test.dart';

import 'package:wakelock_plus_platform_interface/messages.g.dart';


class _PigeonCodec extends StandardMessageCodec {
const _PigeonCodec();
@override
void writeValue(WriteBuffer buffer, Object? value) {
if (value is int) {
buffer.putUint8(4);
buffer.putInt64(value);
} else if (value is ToggleMessage) {
} else if (value is ToggleMessage) {
buffer.putUint8(129);
writeValue(buffer, value.encode());
} else if (value is IsEnabledMessage) {
} else if (value is IsEnabledMessage) {
buffer.putUint8(130);
writeValue(buffer, value.encode());
} else {
Expand All @@ -32,9 +31,9 @@ class _PigeonCodec extends StandardMessageCodec {
@override
Object? readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
case 129:
case 129:
return ToggleMessage.decode(readValue(buffer)!);
case 130:
case 130:
return IsEnabledMessage.decode(readValue(buffer)!);
default:
return super.readValueOfType(type, buffer);
Expand All @@ -43,25 +42,37 @@ class _PigeonCodec extends StandardMessageCodec {
}

abstract class TestWakelockPlusApi {
static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance;
static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding =>
TestDefaultBinaryMessengerBinding.instance;
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();

void toggle(ToggleMessage msg);

IsEnabledMessage isEnabled();

static void setUp(TestWakelockPlusApi? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) {
messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
static void setUp(
TestWakelockPlusApi? api, {
BinaryMessenger? binaryMessenger,
String messageChannelSuffix = '',
}) {
messageChannelSuffix =
messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
{
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.toggle$messageChannelSuffix', pigeonChannelCodec,
final BasicMessageChannel<
Object?> pigeonVar_channel = BasicMessageChannel<
Object?>(
'dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.toggle$messageChannelSuffix',
pigeonChannelCodec,
binaryMessenger: binaryMessenger);
if (api == null) {
_testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler<Object?>(pigeonVar_channel, null);
_testBinaryMessengerBinding!.defaultBinaryMessenger
.setMockDecodedMessageHandler<Object?>(pigeonVar_channel, null);
} else {
_testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler<Object?>(pigeonVar_channel, (Object? message) async {
_testBinaryMessengerBinding!.defaultBinaryMessenger
.setMockDecodedMessageHandler<Object?>(pigeonVar_channel,
(Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.toggle was null.');
'Argument for dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.toggle was null.');
final List<Object?> args = (message as List<Object?>?)!;
final ToggleMessage? arg_msg = (args[0] as ToggleMessage?);
assert(arg_msg != null,
Expand All @@ -71,27 +82,35 @@ abstract class TestWakelockPlusApi {
return wrapResponse(empty: true);
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(error: PlatformException(code: 'error', message: e.toString()));
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
{
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.isEnabled$messageChannelSuffix', pigeonChannelCodec,
final BasicMessageChannel<
Object?> pigeonVar_channel = BasicMessageChannel<
Object?>(
'dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.isEnabled$messageChannelSuffix',
pigeonChannelCodec,
binaryMessenger: binaryMessenger);
if (api == null) {
_testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler<Object?>(pigeonVar_channel, null);
_testBinaryMessengerBinding!.defaultBinaryMessenger
.setMockDecodedMessageHandler<Object?>(pigeonVar_channel, null);
} else {
_testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler<Object?>(pigeonVar_channel, (Object? message) async {
_testBinaryMessengerBinding!.defaultBinaryMessenger
.setMockDecodedMessageHandler<Object?>(pigeonVar_channel,
(Object? message) async {
try {
final IsEnabledMessage output = api.isEnabled();
return <Object?>[output];
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(error: PlatformException(code: 'error', message: e.toString()));
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
Expand Down

0 comments on commit 8dd3673

Please sign in to comment.