Created
November 7, 2020 22:07
-
-
Save Ayush783/b2622136afef8c305a5b42bc33901664 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Capture { | |
File image; | |
final picker = ImagePicker(); //instantiate the image picker object | |
Future<CapturedImage> getImage() async { | |
final pickedFile = | |
await picker.getImage(source: ImageSource.camera, imageQuality: 50); //capture the image | |
if (pickedFile != null) { | |
image = File(pickedFile.path); | |
return CapturedImage.fromFile(image); //if image is not null return our image model with the image | |
} else { | |
return CapturedImage.fromError('Please try again'); // else return with error | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment