Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example app might block #74

Open
chenfisher opened this issue Mar 21, 2024 · 1 comment
Open

Example app might block #74

chenfisher opened this issue Mar 21, 2024 · 1 comment
Assignees

Comments

@chenfisher
Copy link

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);

@andretortolano andretortolano self-assigned this Mar 25, 2024
@andretortolano
Copy link
Contributor

Thank you for the feedback, we will look into that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants