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) {
    List imageList = (state as ImageListState).images;
    imageList[index].imageUrl = File(image.path);
    add(ImageListEvent(imageList));
  }
}