supportedTorchModes method

  1. @override
Future<List<TorchMode>> supportedTorchModes()
override

Retrieve all supported torch modes for a device.

Implementation

@override
Future<List<TorchMode>> supportedTorchModes() async {
  verifyInitialized();
  verifyNotDisposed();
  if (!device.device.hasTorch) return <TorchMode>[];

  final List<int> torchModes = await device.device.torchModesSupported(
    <int>[CaptureTorchMode.on, CaptureTorchMode.off],
  );

  for (int mode in torchModes) {
    if (mode == CaptureTorchMode.on) {
      return <TorchMode>[TorchMode.on, TorchMode.off];
    }
  }

  return <TorchMode>[];
}