askPermission method

dynamic askPermission(
  1. bool isFromPicker,
  2. PermissionType permissionType,
  3. int index
)

Asking permission (Platform specific)

Implementation

askPermission(bool isFromPicker, PermissionType permissionType, int index) async {
  Map<Permission, PermissionStatus> statuses = {};

  /// You can request multiple permissions at once.
  if (Platform.isIOS) {
    statuses = await [
      Permission.photos,
      Permission.storage,
    ].request();
  } else {
    statuses = await [Permission.camera, Permission.storage].request();
  }
  bool isForStorage = permissionType == PermissionType.storage;
  if (isForStorage) {
    if (Platform.isIOS) {
      ///For iOS we need to access photos
      await Permission.photos.request().then((value) => eventAction(isForStorage, isFromPicker, permissionType, index, statuses));
    } else {
      ///For Android we need to access storage
      await Permission.storage.request().then((value) => eventAction(isForStorage, isFromPicker, permissionType, index, statuses));
    }
  } else {
    ///If coming from camera then we need to take permission of camera (In both platform)
    await Permission.camera.request().then((value) => eventAction(isForStorage, isFromPicker, permissionType, index, statuses));
  }
}