toggleTorch method

  1. @override
Future<void> toggleTorch({
  1. required bool enabled,
})
override

Can enable or disable the flash if available

Implementation

@override
Future<void> toggleTorch({required bool enabled}) async {
  final hasTorch = await this.hasTorch();
  if (hasTorch) {
    final track = localMediaStream?.getVideoTracks();
    await track?.first.applyConstraints({
      'advanced': [
        {'torch': enabled},
      ],
    });
  }
}