diff --git a/packages/pigeon/CHANGELOG.md b/packages/pigeon/CHANGELOG.md index 8b083f767042..13033b336a87 100644 --- a/packages/pigeon/CHANGELOG.md +++ b/packages/pigeon/CHANGELOG.md @@ -1,3 +1,7 @@ +## 19.0.2 + +* [kotlin] Adds the `@JvmOverloads` to the `HostApi` setUp method. This prevents the calling Java code from having to provide an empty `String` as Kotlin provides it by default + ## 19.0.1 * [dart] Updates `PigeonInstanceMangerApi` to use the shared api channel code. diff --git a/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt b/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt index 48981666f24b..7f0e75cefa9d 100644 --- a/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt +++ b/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt @@ -118,6 +118,7 @@ interface ExampleHostApi { /** The codec used by ExampleHostApi. */ val codec: MessageCodec by lazy { ExampleHostApiCodec } /** Sets up an instance of `ExampleHostApi` to handle messages through the `binaryMessenger`. */ + @JvmOverloads fun setUp( binaryMessenger: BinaryMessenger, api: ExampleHostApi?, diff --git a/packages/pigeon/lib/generator_tools.dart b/packages/pigeon/lib/generator_tools.dart index 85c2a2c75abd..a02efc0fe84b 100644 --- a/packages/pigeon/lib/generator_tools.dart +++ b/packages/pigeon/lib/generator_tools.dart @@ -13,7 +13,7 @@ import 'ast.dart'; /// The current version of pigeon. /// /// This must match the version in pubspec.yaml. -const String pigeonVersion = '19.0.1'; +const String pigeonVersion = '19.0.2'; /// Prefix for all local variables in methods. /// diff --git a/packages/pigeon/lib/kotlin_generator.dart b/packages/pigeon/lib/kotlin_generator.dart index 18df439d740d..e805034ee2c1 100644 --- a/packages/pigeon/lib/kotlin_generator.dart +++ b/packages/pigeon/lib/kotlin_generator.dart @@ -430,6 +430,7 @@ class KotlinGenerator extends StructuredGenerator { }); indent.writeln( '/** Sets up an instance of `$apiName` to handle messages through the `binaryMessenger`. */'); + indent.writeln('@JvmOverloads'); indent.write( 'fun setUp(binaryMessenger: BinaryMessenger, api: $apiName?, messageChannelSuffix: String = "") '); indent.addScoped('{', '}', () { diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml index fa7ffcc9ca97..edbba1f4027b 100644 --- a/packages/pigeon/pubspec.yaml +++ b/packages/pigeon/pubspec.yaml @@ -2,7 +2,7 @@ name: pigeon description: Code generator tool to make communication between Flutter and the host platform type-safe and easier. repository: https://github.com/flutter/packages/tree/main/packages/pigeon issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+pigeon%22 -version: 19.0.1 # This must match the version in lib/generator_tools.dart +version: 19.0.2 # This must match the version in lib/generator_tools.dart environment: sdk: ^3.2.0 diff --git a/packages/pigeon/test/kotlin_generator_test.dart b/packages/pigeon/test/kotlin_generator_test.dart index 2051e4a12a52..40c1e75c3aad 100644 --- a/packages/pigeon/test/kotlin_generator_test.dart +++ b/packages/pigeon/test/kotlin_generator_test.dart @@ -231,6 +231,10 @@ void main() { final String code = sink.toString(); expect(code, contains('interface Api')); expect(code, contains('fun doSomething(input: Input): Output')); + expect(code, contains(''' + @JvmOverloads + fun setUp(binaryMessenger: BinaryMessenger, api: Api?, messageChannelSuffix: String = "") { + ''')); expect(code, contains('channel.setMessageHandler')); expect(code, contains(''' if (api != null) {