Can not switch camera while recording with camera plugin, setDescription working but preview doesn't change

14 Views Asked by At

I am trying to switch camera while recording but it doesn't work. When I am not recording it works fine. I am using camera plugin.

I am switching between cameras like this

Future<void> changeCameraLens() async {
final cameras = ref.read(availableCamerasProvider);
if (cameras.length > 1) {
  if (state.description.lensDirection == CameraLensDirection.front) {
    await state.setDescription(cameras.first);
  } else {
    await state.setDescription(cameras.firstWhere(
        (element) => element.lensDirection == CameraLensDirection.front));
  }
}}

I tried initializing again but it didn't work too. I am using setDescription method to switch but it doesn't properly work while I am recording.

0

There are 0 best solutions below