Skip to content

agacemi/flutter_google_wallet

 
 

Repository files navigation

flutter_google_wallet

A Flutter Google Wallet Plugin for tickets

pub package Test codecov License: MIT

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,
  ],

About

A Flutter Plugin for Google Wallet Sdk

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dart 74.7%
  • Java 15.1%
  • Kotlin 9.4%
  • Shell 0.8%