Dart / Flutter package to work with Google My Business API. Simplifies communication & interaction with GMB API endpoints.
More info on Google My Business at Google My Business Google My Business API reference can be found here
NOTICE: Package is in active development, so some APIs might have breaking changes from version to version before 1.0.0
Uses a Flutter plugin Google Sign In for authentication.
Supported endpoints:
Example simple app can be found at /example
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();
All managers are responsible for managing their entity, e.g. account, location, review etc. All of the follow generally the same structure. Some examples of usage can be found below.
Retrieve accounts:
_accountsManager = AccountsManager();
// ...
await _accountsManager.fetchAccounts((accounts) {
print("Total accounts: ${accounts.length}");
setState(() {
_accounts = accounts;
_isLoading = false;
});
}, (error) {
print('Google My Business API: ${error.code} - ${error.message}');
setState(() {
_isLoading = false;
});
});
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;
});
});