setFlashType method

Future<void> setFlashType(
  1. FlashType flashType
)

set the flash light type is auto, on, off, torch

Implementation

Future<void> setFlashType(FlashType flashType) async {
  // TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
  String flashTypeString;

  switch (flashType) {
    case FlashType.auto:
      flashTypeString = "auto";
      break;
    case FlashType.on:
      flashTypeString = "on";
      break;
    case FlashType.off:
      flashTypeString = "off";
      break;
    case FlashType.torch:
      flashTypeString = "torch";
      break;
  }
  var x = await channel
      .invokeMethod('setFlashType', {"flashType": flashTypeString});

  print("setFlashType => $x");
}