pickImage method
Implementation
Future<Uint8List?> pickImage() async {
Uint8List? fileContents;
// ignore: omit_local_variable_types
FilePickerResult? result = await FilePicker.platform
.pickFiles(type: FileType.image, allowMultiple: false);
if (result != null) {
for (var pickedFile in result.files) {
var path = pickedFile.path!;
var file = File(path);
var compressedFile = await FlutterImageCompress.compressWithFile(
file.absolute.path,
minWidth: 400,
minHeight: 200,
);
fileContents = compressedFile;
}
}
return fileContents;
}