Created
June 12, 2019 11:04
-
-
Save ShivamGoyal1899/27dfff85fc3701adaeb758757502d18b 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
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