flutter_wallet_card
iOS और Android के लिए Flutter वॉलेट कार्ड प्लगइन। स्थानीय फ़ाइलों या वेब URL से Apple Wallet पास और Google Wallet कार्ड जनरेट करें।
Flutter वॉलेट कार्ड प्लगइन (iOS और Android)
^4.0.0^3.0.3^2.0.5{"sdk":"flutter"}^4.9.0^1.8.3^2.1.2^4.3.3^2.4.7^4.0.0{"sdk":"flutter"}^6.7.1^5.4.4^1.25.15यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।
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.
Add this to your package's pubspec.yaml file:
dependencies:
flutter_wallet_card: ^5.0.0
Then run:
flutter pub get
Enable Wallet capability in your iOS project:
ios/Runner.xcworkspace in XcodeConfigure your Apple Developer account:
Add Google Wallet API to your project:
Ensure your app uses play-services-pay (automatically included by the plugin):
implementation 'com.google.android.gms:play-services-pay:16.5.0'
Update Android manifest (automatically handled by plugin):
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
import 'package:flutter/material.dart';
import 'package:flutter_wallet_card/flutter_wallet_card.dart';
import 'package:flutter_wallet_card/models/wallet_card.dart';
// Check if wallet is available
bool isAvailable = await FlutterWalletCard.isWalletAvailable;
if (isAvailable) {
// Create a wallet card
final card = WalletCard(
id: 'my-card-123',
type: WalletCardType.generic,
platformData: {
// iOS specific data
'passTypeIdentifier': 'pass.com.yourcompany.yourpass',
'teamIdentifier': 'YOUR_TEAM_ID',
// Android specific data
'issuerId': 'your-issuer-id',
'classId': 'your-class-id',
},
metadata: WalletCardMetadata(
title: 'My Awesome Card',
description: 'This is a sample wallet card',
organizationName: 'Your Company',
serialNumber: 'CARD123',
),
visuals: WalletCardVisuals(
backgroundColor: Color(0xFF1E88E5),
foregroundColor: Color(0xFFFFFFFF),
labelColor: Color(0xFFE3F2FD),
),
);
// Add card to wallet
bool success = await FlutterWalletCard.addToWallet(card);
if (success) {
print('Card added successfully!');
}
}
final cardWithLocation = WalletCard(
id: 'location-card',
type: WalletCardType.storeCard,
platformData: {
'passTypeIdentifier': 'pass.com.yourcompany.store',
'teamIdentifier': 'YOUR_TEAM_ID',
},
metadata: WalletCardMetadata(
title: 'Store Loyalty Card',
description: 'Get rewards at our store',
organizationName: 'Your Store',
serialNumber: 'STORE001',
locations: [
WalletCardLocation(
latitude: 37.7749,
longitude: -122.4194,
altitude: 100.0,
relevantText: 'Welcome to our San Francisco store!',
),
],
),
visuals: WalletCardVisuals(
backgroundColor: Color(0xFF4CAF50),
foregroundColor: Color(0xFFFFFFFF),
),
);
// Generate a card file for sharing or storage
File cardFile = await FlutterWalletCard.generateCardFile(card);
print('Card file created at: ${cardFile.path}');
// Download and add a card from a URL
try {
bool success = await FlutterWalletCard.addFromUrl(
'https://example.com/mycard.pkpass',
);
print('Card added: $success');
} catch (e) {
print('Failed to add card from URL: $e');
}
// Parse a wallet card from a local file
WalletCard card = await FlutterWalletCard.parseFromFile(File('/path/to/card.pkpass'));
print('Card title: ${card.metadata.title}');
// iOS: Add multiple cards at once
if (Platform.isIOS) {
List<WalletCard> cards = [card1, card2, card3];
bool success = await FlutterWalletCard.addMultipleToWallet(cards);
}
// Android: Save pass with JWT
if (Platform.isAndroid) {
String jwt = 'your-google-wallet-jwt';
bool success = await FlutterWalletCard.savePassWithJwt(jwt);
// Create a pass link
String link = await FlutterWalletCard.createPassLink({
'objectId': 'your-object-id',
});
}
| Method | Description | Returns |
|---|---|---|
isWalletAvailable |
Check if wallet is available on device (getter) | Future<bool> |
platformType |
Get the current platform type (getter) | WalletPlatformType |
isCardAdded(String identifier) |
Check if specific card is added | Future<bool> |
addToWallet(WalletCard card) |
Add card to wallet | Future<bool> |
addFromFile(File file, {Map? metadata}) |
Add card from existing file | Future<bool> |
addFromUrl(String url, {Map? metadata}) |
Download and add card from URL | Future<bool> |
viewInWallet(String identifier) |
Open card in wallet app | Future<bool> |
generateCardFile(WalletCard card) |
Generate card file | Future<File> |
parseFromFile(File file) |
Parse card from file | Future<WalletCard> |
cleanup({Duration? olderThan}) |
Clean up temporary files | Future<void> |
| Method | Description | Returns |
|---|---|---|
addMultipleToWallet(List<WalletCard> cards) |
Add multiple cards | Future<bool> |
validatePass(File file) |
Validate a pass file | Future<Map<String, dynamic>> |
getPassInfo(String identifier) |
Get detailed pass info | Future<Map<String, dynamic>> |
isValidPass(File file) |
Check if a pass file is valid | Future<bool> |
| Method | Description | Returns |
|---|---|---|
savePassWithJwt(String jwt) |
Save pass using JWT | Future<bool> |
createPassLink(Map<String, dynamic> data) |
Create pass link | Future<String> |
The main model representing a wallet card:
class WalletCard {
final String id;
final WalletCardType type;
final Map<String, dynamic> platformData;
final WalletCardMetadata metadata;
final WalletCardVisuals? visuals;
final File? file;
}
Card information and content:
class WalletCardMetadata {
final String title;
final String? subtitle;
final String? description;
final String organizationName;
final String serialNumber;
final DateTime? expirationDate;
final DateTime? relevantDate;
final List<WalletCardLocation>? locations;
final Map<String, String>? customFields;
}
Card appearance and styling. Colors are stored as Color objects and serialized as hex strings (e.g. #FF0000) in JSON:
class WalletCardVisuals {
final Color? backgroundColor;
final Color? foregroundColor;
final Color? labelColor;
final String? logoText;
final Map<String, String>? images;
}
The plugin throws WalletException for wallet-related errors:
try {
await FlutterWalletCard.addToWallet(card);
} on WalletException catch (e) {
print('Wallet error: ${e.message}');
if (e.originalError != null) {
print('Original error: ${e.originalError}');
}
} catch (e) {
print('General error: $e');
}
Run the test suite:
flutter test
For comprehensive testing:
flutter test test/test_all.dart
If you're upgrading from version 3.x, here are the key changes:
WalletCard model instead of separate iOS/Android modelsOld (v3.x):
// iOS
await FlutterWalletCard.addPasskit(passData);
// Android
await FlutterWalletCard.addGoogleWallet(walletData);
New (v4.x):
// Unified
final card = WalletCard(/* ... */);
await FlutterWalletCard.addToWallet(card);
# Validate package before publishing
./scripts/publish-package.sh validate
# Run comprehensive tests
./scripts/publish-package.sh test
# Create a new release
./scripts/publish-package.sh release --version 1.0.0
# Publish to pub.dev (manual)
./scripts/publish-package.sh publish
This project includes comprehensive GitHub Actions workflows:
CI/CD Pipeline - Automated testing, validation, and quality checks
Package Publishing - Automated pub.dev releases
Release Management - Version bumping and changelog generation
See GitHub Actions Documentation for details.
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
git clone https://github.com/your-username/flutter_wallet_card.gitflutter pub getflutter test./scripts/deploy-docs.sh dev./scripts/publish-package.sh validate to ensure qualityThis project is licensed under the MIT License - see the LICENSE file for details.
See CHANGELOG.md for a detailed list of changes.
Made with ❤️ for the Flutter community