flutter_google_wallet 0.0.3 flutter_google_wallet: ^0.0.3 copied to clipboard
A Flutter Google Wallet Plugin
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(
langue: 'enUS',
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,
],