openCamera static method
Implementation
static Future<void> openCamera({
required BuildContext context,
required String key,
required Function(List<File>) onImagesCaptured,
required Function(String, List<String>?) onBase64ImagesCaptured,
required dynamic imagePickerUtil,
}) async {
PermissionStatus status = await requestCameraPermission();
if (status.isGranted) {
final List<File>? images = await Navigator.push(context,
MaterialPageRoute(builder: (context) => const MultiCameraScreen()));
if (images != null && images.isNotEmpty) {
await imagePickerUtil.addCameraImages(key, images);
onImagesCaptured(images);
onBase64ImagesCaptured(key, imagePickerUtil.base64ImageLists[key]);
} else {
debugPrint('No images were returned from the camera screen');
}
} else if (status.isDenied) {
showSnackBarMessage(context, 'Please allow the app to access the camera');
} else if (status.isPermanentlyDenied) {
showSnackBarMessage(context,
'Camera permission permanently denied. Please enable it from app settings.');
openAppSettings();
}
}