Skip to content
This repository was 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
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions packages/camera/camera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.7.0+1

* Ensure communication from JAVA to Dart is done on the main UI thread.

## 0.7.0

* BREAKING CHANGE: `CameraValue.aspectRatio` now returns `width / height` rather than `height / width`. [(commit)](https://github.com/flutter/plugins/commit/100c7470d4066b1d0f8f7e4ec6d7c943e736f970)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package io.flutter.plugins.camera;

import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import io.flutter.embedding.engine.systemchannels.PlatformChannel;
Expand Down Expand Up @@ -104,7 +106,14 @@ void send(CameraEventType eventType, Map<String, Object> args) {
if (cameraChannel == null) {
return;
}
cameraChannel.invokeMethod(eventType.method, args);
new Handler(Looper.getMainLooper())
.post(
new Runnable() {
@Override
public void run() {
cameraChannel.invokeMethod(eventType.method, args);
}
});
}

void send(DeviceEventType eventType) {
Expand All @@ -115,6 +124,13 @@ void send(DeviceEventType eventType, Map<String, Object> args) {
if (deviceChannel == null) {
return;
}
deviceChannel.invokeMethod(eventType.method, args);
new Handler(Looper.getMainLooper())
.post(
new Runnable() {
@Override
public void run() {
deviceChannel.invokeMethod(eventType.method, args);
}
});
}
}
2 changes: 1 addition & 1 deletion packages/camera/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera
description: A Flutter plugin for getting information about and controlling the
camera on Android and iOS. Supports previewing the camera feed, capturing images, capturing video,
and streaming image buffers to dart.
version: 0.7.0
version: 0.7.0+1
homepage: https://github.com/flutter/plugins/tree/master/packages/camera/camera

dependencies:
Expand Down