google_my_business 0.3.4 google_my_business: ^0.3.4 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 Google My Business at Google My Business Google My Business API reference can be found here
Getting Started #
NOTICE: Package is in active development, so some APIs might have breaking changes from version to version before 1.0.0
Authentication #
Uses a Flutter plugin Google Sign In for authentication.
API #
Supported endpoints:
Examples #
Example simple app can be found at /example
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();
Managers
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.
Accounts
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;
});
});
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;
});
});