Skip to content

Commit

Permalink
[camera] Ensure that channel.invokeMethod runs on the main thread (fl…
Browse files Browse the repository at this point in the history
  • Loading branch information
jsroest authored and adsonpleal committed Feb 26, 2021
1 parent a6a2caf commit b2910a5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
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

0 comments on commit b2910a5

Please sign in to comment.