Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[camera] Ensure that channel.invokeMethod runs on the main thread #3444

Merged
merged 6 commits into from
Jan 21, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.flutter.plugins.camera;

import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import io.flutter.plugin.common.BinaryMessenger;
Expand Down Expand Up @@ -64,6 +66,11 @@ void send(EventType eventType, Map<String, Object> args) {
if (channel == null) {
return;
}
channel.invokeMethod(eventType.toString().toLowerCase(), args);
new Handler(Looper.getMainLooper()).post(new Runnable () {
@Override
public void run () {
channel.invokeMethod(eventType.toString().toLowerCase(), args);
}
});
}
}