openPicker method

dynamic openPicker(
  1. PermissionType permissionType,
  2. int index
)

Open picker dialog for photo selection

Implementation

openPicker(PermissionType permissionType, int index) async {
  PickedFile? image = await ImagePicker.platform.pickImage(
      source: permissionType == PermissionType.storage
          ? ImageSource.gallery
          : ImageSource.camera);

  if (image != null) {
    var imageList = (state as ImageListState).images;
    imageList[index].imageUrl = File(image.path);
    add(ImageListEvent(imageList));
  }
}