Skip to content

Instantly share code, notes, and snippets.

@ShivamGoyal1899
Created June 12, 2019 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShivamGoyal1899/27dfff85fc3701adaeb758757502d18b to your computer and use it in GitHub Desktop.
Save ShivamGoyal1899/27dfff85fc3701adaeb758757502d18b to your computer and use it in GitHub Desktop.
Future _getImage(BuildContext context) async {
// Use the image_picker package to prompt the user for a photo from their
// device.
final File image = await ImagePicker.pickImage(
source: ImageSource.camera,
);
// Store the image that was selected.
setState(() {
_image = image;
_isUploading = true;
});
// Make a request to upload the image to Google Photos once it was selected.
final String uploadToken =
await ScopedModel.of<PhotosLibraryApiModel>(context)
.uploadMediaItem(image);
setState(() {
// Once the upload process has completed, store the upload token.
// This token is used together with the description to create the media
// item later.
_uploadToken = uploadToken;
_isUploading = false;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment