google_my_business 0.2.1
google_my_business: ^0.2.1 copied to clipboard
Flutter package to work with Google My Business API. Simplifies communication & interaction with GMB API endpoints.
Google My Business for Flutter #
Dart / Flutter package to work with Google My Business API. Simplifies communication & interaction with GMB API endpoints.
More info on GMB API at Google My Business
Getting Started #
Authentication #
Uses a Flutter plugin Google Sign In for authentication.
API #
Supported endpoints:
Examples #
Example simple app can be found at /examples
Login
Init (subscribes for user changes, e.g. user signed in / signed out):
GoogleMyBusiness.instance.init((user) {
setState(() {
_currentUser = user;
});
});
In case you would like to sign in manually:
GoogleMyBusiness.instance.signIn().then((user) {
setState(() {
_currentUser = user;
// Use other API, open a new page or whatever
// to access user, use GoogleMyBusiness.instance.currentUser()
});
});
To sign out current user:
GoogleMyBusiness.instance.signOut();
Locations
Retrieve locations:
_locationsManager = LocationsManager(accountId: "my-account-id");
// ...
await _locationsManager.fetchLocations((locations) {
print("Total locations: ${locations.length}");
setState(() {
_locations = locations;
_isLoading = false;
});
}, (error) {
print('Google My Business API: ${error.code} - ${error.message}');
setState(() {
_isLoading = false;
});
});