toggleFlashlight method

  1. @override
Future<Map<String, dynamic>> toggleFlashlight()
override

Toggle flashlight

Implementation

@override
Future<Map<String, dynamic>> toggleFlashlight() async {
  try {
    if (kDebugMode) {
      debugPrint('QuickQR Scanner: Toggling flashlight');
    }

    final result = await methodChannel.invokeMethod<Map<Object?, Object?>>('toggleFlashlight');
    final flashlightState = Map<String, dynamic>.from(result ?? {});

    if (kDebugMode) {
      debugPrint('QuickQR Scanner: Flashlight toggled - $flashlightState');
    }

    return flashlightState;
  } on PlatformException catch (e) {
    throw _handlePlatformException(e, 'toggleFlashlight');
  } catch (e) {
    throw ScannerException(
      ScannerErrorCode.internalError,
      'Failed to toggle flashlight: $e',
    );
  }
}