Skip to content

Example app might block #74

@chenfisher

Description

@chenfisher

I believe there's a bug in the example app:

Android, MainActivity:

        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(...)
        }
  1. MethodChannel(flutterEngine.dartExecutor, CHANNEL).setMethodCallHandler { call, result ->

  2. _startUri().then(_onRedirected);

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions