g123k / flutter_torch_compat

A plugin to enable or disable the torch of a device that works both on Android (including Android 4.x) and iOS.
https://pub.dev/packages/torch_compat
Apache License 2.0
7 stars 22 forks source link

Problems when using CameraPreview #2

Closed sgehrman closed 4 years ago

sgehrman commented 4 years ago

I'm trying to turn the flash on when I show a CameraPreview. If I turn on the flash before showing the preview, the flash immediately turns off when the preview comes up. And when I try and turn off the light after dismissing the preview, I get:

MissingPluginException (MissingPluginException(No implementation found for method turnOff on channel g123k/torch_compat))

Which is strange since if I put the call in a delay, it works without that exception.

await Future.delayed(const Duration(seconds: 3), () async {
  await TorchCompat.turnOff();
});

So, opening a cameraPreview messes with your plugin somehow and it won't work until the cameraPreview is torn down completely.

sgehrman commented 4 years ago

same problem on flutter_torch MissingPluginException (MissingPluginException(No implementation found for method turnOff on channel flutter_torch))

g123k commented 4 years ago

Yes that's normal (and it's not a bug from this library) You can only have one connection to the camera (the preview has already one).

sgehrman commented 4 years ago

can I turn on the torch using CameraPreview?