requestPermissionWith method

void requestPermissionWith(
  1. Permission permission,
  2. bool isPicker, {
  3. dynamic callBackMultiPickerImages(
    1. List<PlatformFile> files
    )?,
  4. dynamic callBackMultiPickerCamera(
    1. List<PlatformFile> files
    )?,
  5. dynamic callBackPickerCamera(
    1. File file
    )?,
  6. dynamic callBackPickerImage(
    1. File file
    )?,
})

Implementation

void requestPermissionWith(Permission permission, bool isPicker,
    {Function(List<PlatformFile> files)? callBackMultiPickerImages,
    Function(List<PlatformFile> files)? callBackMultiPickerCamera,
    Function(File file)? callBackPickerCamera,
    Function(File file)? callBackPickerImage}) {
  PermissionHelper()
      .requestPermissions(
          isPicker ? [Permission.mediaLibrary] : [Permission.camera])
      .then((permission) async {
    if (permission.isNotEmpty == true) {
      if (permission[isPicker ? Permission.mediaLibrary : Permission.camera]!
          .isGranted) {
        if (isPicker) {
          if (callBackPickerImage != null) {
            await getSingleImage(callBackPickerImage: callBackPickerImage);
          } else if (callBackMultiPickerImages != null) {
            await getSingleImage(
                callBackMultiPickerImage: callBackMultiPickerImages);
          }
        } else {
          if (callBackPickerCamera != null) {
            await getSingleCamera(callBackPickerCamera: callBackPickerCamera);
          } else if (callBackMultiPickerCamera != null) {
            await getSingleCamera(
                callBackMultiPickerCamera: callBackMultiPickerCamera);
          }
        }
      }
    }
  });
}