getSingleCamera method
Future<void>
getSingleCamera(
{ - dynamic callBackMultiPickerCamera(
- List<PlatformFile> files
)?,
- dynamic callBackPickerCamera(
- File file
)?,
- bool? isMultiImage = false,
})
Implementation
Future<void> getSingleCamera(
{Function(List<PlatformFile> files)? callBackMultiPickerCamera,
Function(File file)? callBackPickerCamera,
bool? isMultiImage = false}) async {
final singlePicker = ImagePicker();
final pickedImage =
await singlePicker.pickImage(source: (ImageSource.camera));
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 (callBackMultiPickerCamera != null) {
callBackMultiPickerCamera(fileList);
}
} else {
if (callBackPickerCamera != null) {
callBackPickerCamera(File(
pickedImage.path,
));
}
}
} else {
showLogI('No Image Selected');
}
}