pickImage function

Future<File?> pickImage({
  1. bool useCamera = false,
})

Implementation

Future<File?> pickImage({bool useCamera = false}) async {
  final pickedFile = await _picker.pickImage(
    source: useCamera ? ImageSource.camera : ImageSource.gallery,
  );
  if (pickedFile != null) {
    if (Platform.isLinux || Platform.isWindows || Platform.isMacOS) {
      return File(pickedFile.path);
    }
    final compressedFile = await _compressImage(File(pickedFile.path));
    if (compressedFile != null) return compressedFile;
  }
  return null;
}