MethodChannel(flutterEngine.dartExecutor, CHANNEL).setMethodCallHandler { call, result ->
if (call.method == "initialLink") {
if (startString != null) {
result.success(startString)
}
}
}
In most cases, the app is launched "normally" and not through a deep link, which means startString would be null.
if startString is null or if the method is not initialLink, no result will be sent to the Flutter end.
If the caller is using await, the code would block indefinitely.
In your Flutter code, you use then on the future, and therefore do not see the blocking issue:
_startUri().then(_onRedirected);
But if your code would have used async/await it would not have worked.
A possible solution would be to send a result in any case:
MethodChannel(flutterEngine.dartExecutor, CHANNEL).setMethodCallHandler { call, result ->
if (call.method == "initialLink") {
result.success(startString)
}
result.error(...)
}
I believe there's a bug in the example app:
Android, MainActivity:
In most cases, the app is launched "normally" and not through a deep link, which means
startString
would be null.if
startString
is null or if the method is not initialLink, no result will be sent to the Flutter end. If the caller is usingawait
, the code would block indefinitely.In your Flutter code, you use
then
on the future, and therefore do not see the blocking issue:But if your code would have used
async/await
it would not have worked.A possible solution would be to send a result in any case:
https://github.com/appcues/appcues-flutter-plugin/blob/68c35fb8e62e2cc5b8836b2f273a4cda0791e51e/example/android/app/src/main/kotlin/com/appcues/samples/flutter/MainActivity.kt#L25
https://github.com/appcues/appcues-flutter-plugin/blob/68c35fb8e62e2cc5b8836b2f273a4cda0791e51e/example/lib/src/app.dart#L64