getFlashType method

Future<List<FlashType>> getFlashType()

Implementation

Future<List<FlashType>> getFlashType() async {
  final types = await channel.invokeMethod('getFlashType');

  List<FlashType> finalTypes = [];

  if (types == null) return finalTypes;

  if (types is List) {
    for (var each in types) {
      if (each == "on") {
        finalTypes.add(FlashType.on);
      } else if (each == "off") {
        finalTypes.add(FlashType.off);
      } else if (each == "torch") {
        finalTypes.add(FlashType.torch);
      } else if (each == "auto") {
        finalTypes.add(FlashType.auto);
      }
    }
  }

  return finalTypes;
}