You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3742a4e
Browse filesBrowse the repository at this point in the historyBrowse files
Adds a new class for each event channel API that wraps the underlying EventChannel and allows setting the stream handler, matching the underlying Flutter API. This allows clients that need to set a new handler later (notably, removing a handler to avoid an engine-lifetime reference to a handler for a transient channel) to do so, using the same API that non-Pigeon event channel code would use.
The existing static `register` method is kept to avoid unnecessary breaking changes, but clients no longer need to use it if they want to create the channel directly.
Fixesflutter/flutter#195049
## Pre-Review Checklist
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
Copy file name to clipboardExpand all lines: packages/pigeon/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
## 29.1.0
2
+
3
+
*[kotlin,swift] Adds support for removing event channel handler registration
4
+
via a new event channel object returned from `register`.
5
+
1
6
## 29.0.13
2
7
3
8
*[dart] Separates generated Dart native interop bindings into a conditionally imported companion file (`*.native_interop.g.dart`) so that the main generated Dart file can be imported on Web without pulling in `dart:ffi` or `dart:io`.
Copy file name to clipboardExpand all lines: packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/EventChannelMessages.g.kt
+42-14Lines changed: 42 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -241,10 +241,10 @@ private open class EventChannelMessagesPigeonCodec : StandardMessageCodec() {
* Sets the stream handler for this channel, replacing any previous handler.
1491
+
*
1492
+
* Pass `null` to remove the event channel registration.
1493
+
*/
1494
+
fun setStreamHandler(streamHandler: $streamHandlerClassName?) {
1495
+
val internalHandler = streamHandler?.let { ${generatorOptions.fileSpecificClassNameComponent}PigeonStreamHandler<${_kotlinTypeForDartType(func.returnType)}>(it) }
1496
+
channel.setStreamHandler(internalHandler)
1497
+
}
1498
+
}
1499
+
1500
+
abstract class $streamHandlerClassName : ${generatorOptions.fileSpecificClassNameComponent}PigeonEventChannelWrapper<${_kotlinTypeForDartType(func.returnType)}> {
1476
1501
companion object {
1477
-
fun register(messenger: BinaryMessenger, streamHandler: ${toUpperCamelCase(func.name)}StreamHandler, instanceName: String = "") {
1478
-
var channelName: String = "${makeChannelName(api, func, dartPackageName)}"
1479
-
if (instanceName.isNotEmpty()) {
1480
-
channelName += ".\$instanceName"
1481
-
}
1482
-
val internalStreamHandler = ${generatorOptions.fileSpecificClassNameComponent}PigeonStreamHandler<${_kotlinTypeForDartType(func.returnType)}>(streamHandler)
Copy file name to clipboardExpand all lines: packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/CoreTests.gen.kt
+9-11Lines changed: 9 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -1078,33 +1078,31 @@ private open class CoreTestsPigeonCodec : StandardMessageCodec() {
0 commit comments