jonataslaw / jonataslaw/VideoCompress

Running from isolate throws exception

Open
#242 0 comments 7 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
262
Forks
344
PR merge metrics
No merged PRs in 30d

Description

I am trying o run the code from an isolate, but I get the following exception:

> 'Cannot set the method call handler before the binary messenger has been initialized. '
> 'This happens when you call setMethodCallHandler() before the WidgetsFlutterBinding '
> 'has been initialized. You can fix this by either calling WidgetsFlutterBinding.ensureInitialized() '
> 'before this or by passing a custom BinaryMessenger instance to MethodChannel().',

Fired from:
```dart
class CompressMixin {
final compressProgress$ = ObservableBuilder();
final _channel = const MethodChannel('video_compress');

@protected
void initProcessCallback() {
_channel.setMethodCallHandler(_progressCallback); // <<===== From here
}
```

I have written as [SO question](https://stackoverflow.com/questions/76648668/is-is-possible-to-use-videocompress-plugin-in-an-isolate)

My code is as follows:

```dart
// === Compressing
try {
isolateSwitchToState(RecordingState.compressingVideo);

// == Subscribe to progress ====> EXCEPTION RIGHT HERE <=====
_subscription = VideoCompress.compressProgress$.subscribe((progress) {
debugPrint('progress: $progress');
_send2main?.send(progress);
});

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.