pickCameraImage static method
Launches the device camera to capture an image.
Opens the device's camera application and allows the user to take a photo. Returns the file path of the captured image.
Parameters:
picker: An ImagePicker instance to handle the camera interaction
Returns the file path (String) of the captured image.
Throws an exception if the user cancels or if camera access is denied.
Example:
final picker = ImagePicker();
try {
final imagePath = await RtCommonFunction.pickCameraImage(picker);
print('Image captured at: $imagePath');
} catch (e) {
print('Camera cancelled or error: $e');
}
See also:
- pickGalleryImage for selecting from gallery
Implementation
static Future<String> pickCameraImage(ImagePicker picker) async {
final XFile? pickedFile =
await picker.pickImage(source: ImageSource.camera);
return pickedFile!.path;
}