Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
## 14.0.0

* **Breaking change** [dart] Renames locally defined host API variables.
* [dart] Host api static field `codec` changed to `pigeonChannelCodec`.
* [dart] Adds named parameters to host API methods.
* [dart] Adds optional parameters to host API methods.
* [dart] Adds default values for class constructors and host API methods.
* Adds `isEnum` and `isClass` to `TypeDeclaration`s.
* [cpp] Fixes `FlutterError` generation being tied to ErrorOr.

## 13.1.2

* Adds compatibilty with `analyzer` 6.x.
* Adds compatibility with `analyzer` 6.x.

## 13.1.1

Expand Down Expand Up @@ -159,7 +169,7 @@
* [java] Adds a `GeneratedApi.FlutterError` exception for passing custom error details (code, message, details).
* [kotlin] Adds a `FlutterError` exception for passing custom error details (code, message, details).
* [kotlin] Adds an `errorClassName` option in `KotlinOptions` for custom error class names.
* [java] Removes legacy try catch from async apis.
* [java] Removes legacy try catch from async APIs.
* [java] Removes legacy null check on non-nullable method arguments.
* [cpp] Fixes wrong order of items in `FlutterError`.
* Adds `FlutterError` handling integration tests for all platforms.
Expand Down Expand Up @@ -212,7 +222,7 @@

## 7.2.1

* [kotlin] Fixes Flutter api int errors with updated casting.
* [kotlin] Fixes Flutter API int errors with updated casting.

## 7.2.0

Expand All @@ -238,7 +248,7 @@

## 7.1.2

* [swift] Adds error handling to sync host api methods.
* [swift] Adds error handling to sync host API methods.

## 7.1.1

Expand Down Expand Up @@ -352,7 +362,7 @@

## 4.2.4

* [kotlin] Fixes Kotlin generated sync host api error.
* [kotlin] Fixes Kotlin generated sync host API error.

## 4.2.3

Expand Down Expand Up @@ -831,7 +841,7 @@ class Foo {

## 0.1.0-experimental.11

* Fixed setting an api to null in Java.
* Fixed setting an API to null in Java.

## 0.1.0-experimental.10

Expand Down
117 changes: 62 additions & 55 deletions packages/pigeon/example/app/lib/src/messages.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// 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
// 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, no_leading_underscores_for_local_identifiers

import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
Expand Down Expand Up @@ -98,111 +98,118 @@ class ExampleHostApi {
/// available for dependency injection. If it is left null, the default
/// BinaryMessenger will be used which routes to the host platform.
ExampleHostApi({BinaryMessenger? binaryMessenger})
: _binaryMessenger = binaryMessenger;
final BinaryMessenger? _binaryMessenger;
: __pigeon_binaryMessenger = binaryMessenger;
final BinaryMessenger? __pigeon_binaryMessenger;

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

Future<String> getHostLanguage() async {
const String channelName =
const String __pigeon_channelName =
'dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.getHostLanguage';
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
channelName,
codec,
binaryMessenger: _binaryMessenger,
final BasicMessageChannel<Object?> __pigeon_channel =
BasicMessageChannel<Object?>(
__pigeon_channelName,
pigeonChannelCodec,
binaryMessenger: __pigeon_binaryMessenger,
);
final List<Object?>? replyList = await channel.send(null) as List<Object?>?;
if (replyList == null) {
throw _createConnectionError(channelName);
} else if (replyList.length > 1) {
final List<Object?>? __pigeon_replyList =
await __pigeon_channel.send(null) as List<Object?>?;
if (__pigeon_replyList == null) {
throw _createConnectionError(__pigeon_channelName);
} else if (__pigeon_replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
code: __pigeon_replyList[0]! as String,
message: __pigeon_replyList[1] as String?,
details: __pigeon_replyList[2],
);
} else if (replyList[0] == null) {
} else if (__pigeon_replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
return (replyList[0] as String?)!;
return (__pigeon_replyList[0] as String?)!;
}
}

Future<int> add(int arg_a, int arg_b) async {
const String channelName =
Future<int> add(int a, int b) async {
const String __pigeon_channelName =
'dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.add';
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
channelName,
codec,
binaryMessenger: _binaryMessenger,
final BasicMessageChannel<Object?> __pigeon_channel =
BasicMessageChannel<Object?>(
__pigeon_channelName,
pigeonChannelCodec,
binaryMessenger: __pigeon_binaryMessenger,
);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_a, arg_b]) as List<Object?>?;
if (replyList == null) {
throw _createConnectionError(channelName);
} else if (replyList.length > 1) {
final List<Object?>? __pigeon_replyList =
await __pigeon_channel.send(<Object?>[a, b]) as List<Object?>?;
if (__pigeon_replyList == null) {
throw _createConnectionError(__pigeon_channelName);
} else if (__pigeon_replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
code: __pigeon_replyList[0]! as String,
message: __pigeon_replyList[1] as String?,
details: __pigeon_replyList[2],
);
} else if (replyList[0] == null) {
} else if (__pigeon_replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
return (replyList[0] as int?)!;
return (__pigeon_replyList[0] as int?)!;
}
}

Future<bool> sendMessage(MessageData arg_message) async {
const String channelName =
Future<bool> sendMessage(MessageData message) async {
const String __pigeon_channelName =
'dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.sendMessage';
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
channelName,
codec,
binaryMessenger: _binaryMessenger,
final BasicMessageChannel<Object?> __pigeon_channel =
BasicMessageChannel<Object?>(
__pigeon_channelName,
pigeonChannelCodec,
binaryMessenger: __pigeon_binaryMessenger,
);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_message]) as List<Object?>?;
if (replyList == null) {
throw _createConnectionError(channelName);
} else if (replyList.length > 1) {
final List<Object?>? __pigeon_replyList =
await __pigeon_channel.send(<Object?>[message]) as List<Object?>?;
if (__pigeon_replyList == null) {
throw _createConnectionError(__pigeon_channelName);
} else if (__pigeon_replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
code: __pigeon_replyList[0]! as String,
message: __pigeon_replyList[1] as String?,
details: __pigeon_replyList[2],
);
} else if (replyList[0] == null) {
} else if (__pigeon_replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
return (replyList[0] as bool?)!;
return (__pigeon_replyList[0] as bool?)!;
}
}
}

abstract class MessageFlutterApi {
static const MessageCodec<Object?> codec = StandardMessageCodec();
static const MessageCodec<Object?> pigeonChannelCodec =
StandardMessageCodec();

String flutterMethod(String? aString);

static void setup(MessageFlutterApi? api,
{BinaryMessenger? binaryMessenger}) {
{
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
final BasicMessageChannel<Object?> __pigeon_channel = BasicMessageChannel<
Object?>(
'dev.flutter.pigeon.pigeon_example_package.MessageFlutterApi.flutterMethod',
codec,
pigeonChannelCodec,
binaryMessenger: binaryMessenger);
if (api == null) {
channel.setMessageHandler(null);
__pigeon_channel.setMessageHandler(null);
} else {
channel.setMessageHandler((Object? message) async {
__pigeon_channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.pigeon_example_package.MessageFlutterApi.flutterMethod was null.');
final List<Object?> args = (message as List<Object?>?)!;
Expand Down
Loading