getSingleImage method
Future<void>
getSingleImage(
{ - dynamic callBackMultiPickerImage(
- List<PlatformFile>
)?,
- dynamic callBackPickerImage(
- File file
)?,
- bool? isMultiImage = false,
})
Implementation
Future<void> getSingleImage(
{Function(List<PlatformFile>)? callBackMultiPickerImage,
Function(File file)? callBackPickerImage,
bool? isMultiImage = false}) async {
final singlePicker = ImagePicker();
final pickedImage =
await singlePicker.pickImage(source: (ImageSource.gallery));
if (pickedImage != null) {
if (isMultiImage == true) {
List<PlatformFile> fileList = [];
final files = PlatformFile(
name: pickedImage.name,
size: await pickedImage.length(),
bytes: await pickedImage.readAsBytes(),
path: pickedImage.path,
readStream: pickedImage.readAsBytes().asStream());
fileList.add(files);
if (callBackMultiPickerImage != null) {
callBackMultiPickerImage(fileList);
}
} else {
if (callBackPickerImage != null) {
callBackPickerImage(File(
pickedImage.path,
));
}
}
} else {
showLogI('No Image Selected');
}
}