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

Wrap Flutter Channel method calls to execute on main thread #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chadpav
Copy link

@chadpav chadpav commented Jan 5, 2024

All calls from Native to Flutter must execute on the main UI thread. This PR wraps all calls to the FlutterChannel in DispatchQueue.main.async { ... } to force execution.

See https://docs.flutter.dev/platform-integration/platform-channels#channels-and-platform-threading for more information.

I know this was causing warnings to get printed to the debug console in Flutter. I suspect that could cause intermittent problems at runtime. It's better to address it just in case.

[VERBOSE-2:shell.cc(1004)] The 'sstonn/flutter_watch_os_connectivity_callback' channel sent a message from native to Flutter on a non-platform thread. Platform channel messages must be sent on the platform thread. Failure to do so may result in data loss or crashes, and must be fixed in the plugin or application code creating that channel.

Addresses issue #4

@ChrisElliotUK
Copy link

Can we get this merged in and on pub.dev

@ChrisElliotUK
Copy link

@ssttonn are you able to merge this?

@MattyBoy4444
Copy link

Can this be merged?

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

Successfully merging this pull request may close these issues.

3 participants