flutter_google_wallet
A Flutter Google Wallet Plugin for tickets
Features
- Enable and check if wallet is available
- Add ticket or anything to wallet
Usage
Basic example
Create a FlutterGoogleWalletPlugin instance in your app.
final flutterGoogleWalletPlugin = FlutterGoogleWalletPlugin();
Then, call initWalletClient to create the Wallet instance on Android when you need it in your app.
flutterGoogleWalletPlugin.initWalletClient();
Before display the button, call getWalletApiAvailabilityStatus to know if the device has the wallet app.
FutureBuilder<bool>(
future: flutterGoogleWalletPlugin.getWalletApiAvailabilityStatus(),
Finally, display the button and call savePasses to save ticket in GoogleWallet.
FutureBuilder<bool>(
future: flutterGoogleWalletPlugin.getWalletApiAvailabilityStatus(),
builder: (BuildContext context, AsyncSnapshot<bool> available) {
if (available.data ?? false) {
return AddToGoogleWalletButton(
locale: Locale('en', 'US'),
onPress: () {
widget.flutterGoogleWalletPlugin.savePasses(
jsonPass: '',
addToGoogleWalletRequestCode: 2);
});
} else {
return const SizedBox.shrink();
}
},
),
Also add the google wallet button svg to your pubspec assets
assets:
- packages/flutter_google_wallet/assets/svg/button/frFR_add_to_google_wallet_wallet-button.svg
- packages/flutter_google_wallet/assets/svg/button/enUS_add_to_google_wallet_wallet-button.svg
And add the wallet localization to your MaterialApp
localizationsDelegates: const [
I18nGoogleWallet.delegate,
],
Contribute
To maintain this repository, please first install melos & bootstrap in root directory of the project :
dart pub global activate melos
melos bs
Libraries
- flutter_google_wallet_pigeon
- flutter_google_wallet_platform_interface
- flutter_google_wallet_plugin
- generated/intl/messages_all
- generated/intl/messages_de
- generated/intl/messages_en
- generated/intl/messages_es
- generated/intl/messages_fr
- generated/intl/messages_it
- generated/intl/messages_nl
- generated/l10n
- messages
- utils/locale_utils