pickImage function

Future<File?> pickImage()

Opens the device's gallery and returns a File object representing the selected image.

Implementation

Future<File?> pickImage() async {
  final picker = ImagePicker();
  final pickedFile = await picker.pickImage(source: ImageSource.gallery);
  if (pickedFile != null) {
    return File(pickedFile.path);
  } else {
    return null;
  }
}