WebEferen / flutter_wallet_card

Flutter Wallet Card plugin (iOS & Android)
MIT License
12 stars 23 forks source link
apple card dart flutter google ios pass wallet

Flutter Build Actions Pub Package

flutter_wallet_card

Flutter plugin which allows users to create their own Apple Wallet Passes (as well as Google Cards).

Getting Started

Fetch from URL

Provide URL object for the .passkit file (hosted on www). Library will automatically download it, unpack and add to Apple Wallet if the passkit is valid. It saves all the passkits inside Application Directory and the directory is cleared when next pass is added to save device memory.

import 'package:flutter_wallet_card/flutter_wallet_card.dart';

/// It returns [PasskitFile] object
final passkitFile = await FlutterWalletCard.generateFromUri(
  scheme: 'https',
  host: 'example.com',
  path: '/wallet.pkpass',
  parameters: {
    'someQueryParameter': 'someQueryValue'
  }
);

Fetch from file

Provide absolute path to the .passkit file. Library will automatically unpack it add prepare object that will be ready to add into Apple Wallet if the passkit is valid. It saves all the passkits inside Application Directory and the directory is cleared when next pass is added to save device memory.

import 'package:flutter_wallet_card/flutter_wallet_card.dart';

/// It returns [PasskitFile] object
final passkitFile = await FlutterWalletCard.generateFromFile(
  id: 'example-pass',
  file: File('path-to-file.pkpass'),
);

Generate from scratch

Currently there is no way to generate signature within mobile application althrough, You can find Signer class that is using OpenSSL under-the-hood which allows to generate such a signature certificate. On real device unfortunately, there is no possibility to generate it (yet). For more information check Signer class reference.

import 'package:flutter_wallet_card/flutter_wallet_card.dart';

final passkitGenerated = await FlutterWalletCard.generatePass(
  id: 'example-id',
  pass: PasskitPass(), // class instance
  signature: File('signature'),
  manifest: File('manifest.json'),
  iconImage: PasskitImage(), // class instance
);

final passkitFile = passkitGenerated.passkitFile;

Save it into wallet

Once the passkitFile will be generated, use this command to add it into Apple Wallet. This command will return status whether operation succeeded or not.

/// It accepts [PasskitFile] class instance and returns [bool] 
final completed = await FlutterWalletCard.addPasskit(passkitFile);

Contribute

Please feel free to fork, improve, make pull requests or fill issues. I'll be glad to fix bugs you encountered or improve the extension.

Roadmap

At this moment some of key features are not working as intended to:

Changelog

Refer to the Changelog to get all release notes.