takeImage method
void
takeImage({})
Implementation
void takeImage({
bool imageCamera = true,
var notifCancel,
bool getBase64 = false,
bool getUint8List = false,
Function(ImageData)? result,
}) async {
final pickedFile = await ImagePicker().pickImage(
source: imageCamera ? ImageSource.camera : ImageSource.gallery,
);
if (pickedFile != null) {
// Pick Image
imgPath.value = pickedFile.path;
imgSize.value = imageSize(File(imgPath.value));
imgFile = File(imgPath.value);
if (getBase64) {
final bytesPhoto = File(pickedFile.path).readAsBytesSync();
imgBase64.value = base64Encode(bytesPhoto);
}
if (getUint8List) {
imgUint8List = File(pickedFile.path).readAsBytesSync();
}
if (result != null) {
result(
ImageData(
imgPath: imgPath.value,
imgSize: imageSize(File(imgPath.value)),
imgFile: File(imgPath.value),
imgUint8List: imgUint8List,
imgBase64: imgBase64.value,
),
);
}
update();
} else {
notifCancel;
//toastBottom(message: 'Tidak ada foto yang di ambil !');
}
}