Flutter Wallet Card 是一個插件,可讓 iOS 與 Android 應用透過本機檔案或網頁 URL 產生 Apple Wallet 傳輸證與 Google Wallet 卡片。它簡化了將數位錢包整合至 Flutter 應用程式的過程,讓使用者能直接從應用程式中新增票券、登機證、忠誠度卡等。此插件支援兩個平台,並透過平台通道使用原生錢包 API。非常適合需要無縫數位錢包互動且設定簡單的應用程式。
適用情境
將忠誠卡新增至 Apple Wallet
為旅行應用生成登機證
為票務應用創建活動門票
啟用數位禮品卡
支援健身應用中的會員卡
主要特色
支援 Apple Wallet 與 Google Wallet
從本機檔案或URL產生通行憑證
跨平台(iOS 與 Android)
用於產生通行碼的簡單 API
安全的檔案處理
平台通道整合
適合對象
旅行和活動應用
零售和忠誠度計畫
健身和會員服務
數位票務系統
行動銀行與支付應用
使用建議
需要正確的金鑰檔案格式
需要有效的證書以用於 Apple Wallet
Google Wallet 結合需要特定設定
限於支援的通行證類型
檔案大小和格式限制適用
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
Flutter Wallet Card
A comprehensive Flutter plugin for creating and managing wallet cards on both iOS (Apple Wallet) and Android (Google Wallet). This plugin provides a unified API for generating, adding, and managing wallet passes across platforms.
Features
Cross-Platform Support
iOS: Full Apple Wallet (Passkit) integration
Android: Google Wallet integration
Unified API: Single codebase for both platforms
Card Operations
✅ Check wallet availability
✅ Add cards to wallet
✅ Check if card is already added
✅ View cards in wallet
✅ Generate card files from data
✅ Parse existing card files
✅ Download cards from URLs
Card Types Supported
Generic Cards: General purpose cards
Boarding Passes: Flight tickets
Coupons: Discount and promotional cards
Event Tickets: Concert, sports, and event passes
Store Cards: Loyalty and membership cards
Advanced Features
🎨 Custom colors and styling
📍 Location-based relevance
📅 Date-based relevance
🔒 Secure certificate signing (iOS)
🌐 Network download support
🧪 Comprehensive test coverage
Installation
Add this to your package's pubspec.yaml file:
dependencies:flutter_wallet_card:^5.0.0
Then run:
flutter pub get
Platform Setup
iOS Setup
Enable Wallet capability in your iOS project:
Open ios/Runner.xcworkspace in Xcode
Select your target → Signing & Capabilities
Add "Wallet" capability
Configure your Apple Developer account:
Create a Pass Type ID in Apple Developer Console
Generate certificates for pass signing
Android Setup
Add Google Wallet API to your project:
Enable Google Wallet API in Google Cloud Console
Configure OAuth 2.0 credentials
Ensure your app uses play-services-pay (automatically included by the plugin):
// Generate a card file for sharing or storageFile cardFile = awaitFlutterWalletCard.generateCardFile(card);
print('Card file created at: ${cardFile.path}');
Adding Cards from URLs
// Download and add a card from a URLtry {
bool success = awaitFlutterWalletCard.addFromUrl(
'https://example.com/mycard.pkpass',
);
print('Card added: $success');
} catch (e) {
print('Failed to add card from URL: $e');
}
Parsing Existing Card Files
// Parse a wallet card from a local fileWalletCard card = awaitFlutterWalletCard.parseFromFile(File('/path/to/card.pkpass'));
print('Card title: ${card.metadata.title}');
Platform-Specific Features
// iOS: Add multiple cards at onceif (Platform.isIOS) {
List<WalletCard> cards = [card1, card2, card3];
bool success = awaitFlutterWalletCard.addMultipleToWallet(cards);
}
// Android: Save pass with JWTif (Platform.isAndroid) {
String jwt = 'your-google-wallet-jwt';
bool success = awaitFlutterWalletCard.savePassWithJwt(jwt);
// Create a pass linkString link = awaitFlutterWalletCard.createPassLink({
'objectId': 'your-object-id',
});
}