| // Copyright 2013 The Flutter Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| // |
| // Autogenerated from Pigeon, 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, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import |
| |
| import 'dart:async'; |
| import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; |
| |
| import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; |
| import 'package:flutter/services.dart'; |
| |
| /// This comment is to test enum documentation comments. |
| enum EnumState { |
| /// This comment is to test enum member (Pending) documentation comments. |
| Pending, |
| |
| /// This comment is to test enum member (Success) documentation comments. |
| Success, |
| |
| /// This comment is to test enum member (Error) documentation comments. |
| Error, |
| } |
| |
| /// This comment is to test class documentation comments. |
| class DataWithEnum { |
| DataWithEnum({ |
| this.state, |
| }); |
| |
| /// This comment is to test field documentation comments. |
| EnumState? state; |
| |
| Object encode() { |
| return <Object?>[ |
| state?.index, |
| ]; |
| } |
| |
| static DataWithEnum decode(Object result) { |
| result as List<Object?>; |
| return DataWithEnum( |
| state: result[0] != null ? EnumState.values[result[0]! as int] : null, |
| ); |
| } |
| } |
| |
| class _EnumApi2HostCodec extends StandardMessageCodec { |
| const _EnumApi2HostCodec(); |
| @override |
| void writeValue(WriteBuffer buffer, Object? value) { |
| if (value is DataWithEnum) { |
| buffer.putUint8(128); |
| writeValue(buffer, value.encode()); |
| } else { |
| super.writeValue(buffer, value); |
| } |
| } |
| |
| @override |
| Object? readValueOfType(int type, ReadBuffer buffer) { |
| switch (type) { |
| case 128: |
| return DataWithEnum.decode(readValue(buffer)!); |
| default: |
| return super.readValueOfType(type, buffer); |
| } |
| } |
| } |
| |
| /// This comment is to test api documentation comments. |
| class EnumApi2Host { |
| /// Constructor for [EnumApi2Host]. 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. |
| EnumApi2Host({BinaryMessenger? binaryMessenger}) |
| : _binaryMessenger = binaryMessenger; |
| final BinaryMessenger? _binaryMessenger; |
| |
| static const MessageCodec<Object?> codec = _EnumApi2HostCodec(); |
| |
| /// This comment is to test method documentation comments. |
| Future<DataWithEnum> echo(DataWithEnum arg_data) async { |
| final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( |
| 'dev.flutter.pigeon.pigeon_integration_tests.EnumApi2Host.echo', codec, |
| binaryMessenger: _binaryMessenger); |
| final List<Object?>? replyList = |
| await channel.send(<Object?>[arg_data]) as List<Object?>?; |
| if (replyList == null) { |
| throw PlatformException( |
| code: 'channel-error', |
| message: 'Unable to establish connection on channel.', |
| ); |
| } else if (replyList.length > 1) { |
| throw PlatformException( |
| code: replyList[0]! as String, |
| message: replyList[1] as String?, |
| details: replyList[2], |
| ); |
| } else if (replyList[0] == null) { |
| throw PlatformException( |
| code: 'null-error', |
| message: 'Host platform returned null value for non-null return value.', |
| ); |
| } else { |
| return (replyList[0] as DataWithEnum?)!; |
| } |
| } |
| } |
| |
| class _EnumApi2FlutterCodec extends StandardMessageCodec { |
| const _EnumApi2FlutterCodec(); |
| @override |
| void writeValue(WriteBuffer buffer, Object? value) { |
| if (value is DataWithEnum) { |
| buffer.putUint8(128); |
| writeValue(buffer, value.encode()); |
| } else { |
| super.writeValue(buffer, value); |
| } |
| } |
| |
| @override |
| Object? readValueOfType(int type, ReadBuffer buffer) { |
| switch (type) { |
| case 128: |
| return DataWithEnum.decode(readValue(buffer)!); |
| default: |
| return super.readValueOfType(type, buffer); |
| } |
| } |
| } |
| |
| /// This comment is to test api documentation comments. |
| abstract class EnumApi2Flutter { |
| static const MessageCodec<Object?> codec = _EnumApi2FlutterCodec(); |
| |
| /// This comment is to test method documentation comments. |
| DataWithEnum echo(DataWithEnum data); |
| |
| static void setup(EnumApi2Flutter? api, {BinaryMessenger? binaryMessenger}) { |
| { |
| final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( |
| 'dev.flutter.pigeon.pigeon_integration_tests.EnumApi2Flutter.echo', |
| codec, |
| binaryMessenger: binaryMessenger); |
| if (api == null) { |
| channel.setMessageHandler(null); |
| } else { |
| channel.setMessageHandler((Object? message) async { |
| assert(message != null, |
| 'Argument for dev.flutter.pigeon.pigeon_integration_tests.EnumApi2Flutter.echo was null.'); |
| final List<Object?> args = (message as List<Object?>?)!; |
| final DataWithEnum? arg_data = (args[0] as DataWithEnum?); |
| assert(arg_data != null, |
| 'Argument for dev.flutter.pigeon.pigeon_integration_tests.EnumApi2Flutter.echo was null, expected non-null DataWithEnum.'); |
| final DataWithEnum output = api.echo(arg_data!); |
| return output; |
| }); |
| } |
| } |
| } |
| } |