I'm facing an issue with Pigeon in Flutter. In debug mode, my code fails to bridge between the pigeon_api.dart (file from flutter code) and pigeon_api.kt (file from native android side)
Pigeon_api.dart:
// Autogenerated from Pigeon (v10.1.4), do not edit directly.
...class NavigationApiHost {
NavigationApiHost({BinaryMessenger? binaryMessenger})
: _binaryMessenger = binaryMessenger;
final BinaryMessenger? _binaryMessenger;
static const MessageCodec<Object?> codec = StandardMessageCodec();
Future<void> back() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.cts_lecture_badgeo_flutter.NavigationApiHost.back', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(null) 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 {
return;
}
}
}
pigeon_api.kt
// Autogenerated from Pigeon (v10.1.4), do not edit directly.
...
interface NavigationApiHost {
fun back()
companion object {
/** The codec used by NavigationApiHost. */
val codec: MessageCodec<Any?> by lazy {
StandardMessageCodec()
}
/** Sets up an instance of `NavigationApiHost` to handle messages through the `binaryMessenger`. */
@Suppress("UNCHECKED_CAST")
fun setUp(binaryMessenger: BinaryMessenger, api: NavigationApiHost?) {
run {
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.cts_lecture_badgeo_flutter.NavigationApiHost.back", codec)
if (api != null) {
channel.setMessageHandler { _, reply ->
var wrapped: List<Any?>
try {
api.back()
wrapped = listOf<Any?>(null)
} catch (exception: Throwable) {
wrapped = wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
}
}
}
I've ensured that the channel name between the two files is consistent, and I'm using the same version of Pigeon in both. I've initialized my APIs in the mainActivity of my native code.
mainActivity.kt
class MainActivity : FlutterFragmentActivity() {
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
NavigationApiHostImpl.initNavigationApiHost(flutterEngine, this)
}
}````
Can anyone assist me with this?
I have no error logs ...
Thanks in advance