pickImage method
dynamic
pickImage(
- ImageSource source, {
- BuildContext? context,
})
Implementation
pickImage(ImageSource source, {BuildContext? context}) async {
pickedFile = await imagePicker.getImage(source: source);
imageBytes = await pickedFile!.readAsBytes();
if (imageBytes!.length > 1000 * 1000 * 10) {
cryAlert(Cry.context, limitMessage);
pickedFile = null;
imageBytes = null;
setState(() {});
return;
}
if (pickedFile != null && imageBytes != null) {
widget.onUpload!(imageBytes!);
}
setState(() {});
if (context != null) {
Navigator.pop(context);
}
}