getCapabilities method

  1. @override
Future<TorchCapabilities> getCapabilities()
override

Returns the capabilities of the torch on the current platform.

Implementation

@override
Future<TorchCapabilities> getCapabilities() async {
  final result = await methodChannel.invokeMethod<Map>('get_capabilities');
  if (result == null) {
    return const TorchCapabilities(
      supportsStrength: false,
      supportsBlinking: true,
      supportsBackground: false,
      supportsFade: false,
      supportsSOS: true,
      supportsCustomBlink: true,
    );
  }
  return TorchCapabilities(
    supportsStrength: result['supportsStrength'] as bool? ?? false,
    supportsBlinking: result['supportsBlinking'] as bool? ?? true,
    supportsBackground: result['supportsBackground'] as bool? ?? false,
    supportsFade: result['supportsFade'] as bool? ?? false,
    supportsSOS: result['supportsSOS'] as bool? ?? true,
    supportsCustomBlink: result['supportsCustomBlink'] as bool? ?? true,
  );
}