Skip to content

Instantly share code, notes, and snippets.

@hamza39460
Last active August 31, 2020 07:41
Show Gist options
  • Save hamza39460/61653df6e6868c4faeb243c0876f6b30 to your computer and use it in GitHub Desktop.
Save hamza39460/61653df6e6868c4faeb243c0876f6b30 to your computer and use it in GitHub Desktop.
insertEvent(event){
try {
clientViaUserConsent(_clientID, _scopes, prompt).then((AuthClient client){
var calendar = CalendarApi(client);
String calendarId = "primary";
calendar.events.insert(event,calendarId).then((value) {
print("ADDEDDD_________________${value.status}");
if (value.status == "confirmed") {
log('Event added in google calendar');
} else {
log("Unable to add event in google calendar");
}
});
});
} catch (e) {
log('Error creating event $e');
}
}
void prompt(String url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
@hamza39460
Copy link
Author

when do i use function "prompt() " ?
how i get the "url" ?

I just updated the gist. Sorry I forgot to add it earlier.

@triyono777
Copy link

its working, thanks..., but it always prompt for access calendar, how to use without open browser or hardcode credential maybe?

thank you for the answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment