搜尋套件、儲存庫與 APP 分類

套件詳情v0.13.0

flutter_credit_card_scanner

一個 Flutter 套件,利用裝置相機掃描並擷取信用卡資訊。在 Android 上使用 Google ML,在 iOS 上使用 Apple Vision。

AndroidiOS
近 30 天下載
1520
喜歡數
19
Pub 分數
160

安裝套件

flutter pub add flutter_credit_card_scanner

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 套件,可使用裝置的相機掃描信用卡細節。它在 Android 上利用 Google ML Kit,在 iOS 上利用 Apple Vision,準確檢測並提取卡片資訊。專為無縫整合至付款或結帳流程而設計,透過自動化從實體卡片中擷取資料來簡化使用者輸入。此套件支援兩大主要行動平台,並為應用程式中的安全、高效卡片輸入提供可靠基礎。

適用情境

  • 結帳流程中的自動信用卡輸入
  • 簡化付款表單填寫
  • 將卡片掃描功能整合至金融應用程式中
  • 在電子商務應用中實現快速資料採集
  • 支援數位錢包設定

主要特色

  • 使用 Google ML Kit(Android)
  • 利用 Apple Vision(iOS)
  • 提取卡號、有效期限和姓名
  • 基於相機的掃描介面
  • 跨平台相容性

適合對象

  • 電子商務應用
  • 支付處理工具
  • 金融與銀行應用
  • 數位錢包整合
  • 需要快速卡片輸入的應用程式

使用建議

  • 需要相機權限
  • 準確性取決於卡片的可見性和照明
  • 敏感數據處理必須安全
  • 可能需要額外的驗證步驟
  • 不適用於所有卡片類型或方向

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

🇵🇸 In solidarity with Palestine and all the free people of the world 🇵🇸

CameraScannerWidget

Description:

Introducing a cutting-edge Flutter package that harnesses the power of your device's camera to seamlessly scan and extract credit card information. This innovative solution leverages state-of-the-art machine learning technologies: Google ML Kit for Android devices and Apple Vision for iOS, ensuring optimal performance across platforms.

CameraScannerWidget (
    onScan: (ctx, value) {},
    loadingHolder: CircularProgressIndicator(),
    onNoCamera: () {
        // Handle camera unavailability
    }
)

Demo: Witness the magic in action! 🎥✨

https://github.com/user-attachments/assets/ff6e818c-a65c-4bff-bb95-cbaef2368a23

Key Features:

  • 📱 Cross-platform compatibility (iOS & Android)
  • 🚀 Lightning-fast credit card recognition
  • 🔒 Secure, on-device processing
  • 🎨 Customizable UI elements

Input Parameters:

  • onScan (required): Your gateway to extracted card data! This callback function receives the BuildContext and a CreditCardModel object containing the juicy details (number, holder name, expiration month, expiration year) when a card is successfully scanned.
  • loadingHolder (required): Keep your users engaged! Specify a widget to display during camera initialization.
  • onNoCamera (required): Gracefully handle camera unavailability with this callback function.
  • aspectRatio (optional): Fine-tune your preview! Set the aspect ratio of the camera view (defaults to device screen ratio).
  • cardNumber (optional): Toggle card number scanning (default: true).
  • cardHolder (optional): Enable/disable cardholder name extraction (default: true).
  • cardExpiryDate (optional): Control expiry date scanning (default: true).
  • useLuhnValidation (optional): Enable/disable Luhn validation (default: true).
  • durationOfNextFrame (optional): The duration of the next frame. This can be used to slow down the camera scanning and process the image so it will scan and wait for the next frame to be processed based on the duration. Default is null which means the camera will scan as fast as possible.
  • resolutionPreset (optional): The resolution preset for the camera. Defaults to [ResolutionPreset.high]. This can be used to set the resolution of the camera to a lower resolution to improve performance. Depends on the targeted platform it can be ResolutionPreset.low, ResolutionPreset.medium, ResolutionPreset.high, ResolutionPreset.veryHigh, ResolutionPreset.ultraHigh, ResolutionPreset.max.

Platform-Specific Setup:

Android Configuration:

  1. Ensure your app has integration with Firebase and Google ML Kit, YOU don't need it in IOS.
  2. Upgrade your Android experience! Update android/app/build.gradle:
android {
    defaultConfig {
        minSdkVersion 21
        // ... other configurations
    }
}
  1. Grant camera access! Modify android/app/src/main/AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.your_app_name">

    <uses-permission android:name="android.permission.CAMERA" />

</manifest>

iOS Configuration:

  1. Inform your users! Update ios/Runner/Info.plist:
<key>NSCameraUsageDescription</key>
<string>This app needs camera access to scan credit cards.</string>
  1. Set the stage! Modify ios/Podfile:

platform :ios, '15.5' // minimum deployment target

Don't forget to run pod install in the ios directory!

Example Usage:

import 'package:flutter_credit_card_scanner/flutter_credit_card_scanner.dart';
import 'package:flutter/material.dart';

class MyAppCreditCardScanner extends StatefulWidget {
  const MyAppCreditCardScanner({super.key});

  @override
  State<MyAppCreditCardScanner> createState() => _MyAppCreditCardScannerState();
}

class _MyAppCreditCardScannerState extends State<MyAppCreditCardScanner> {
  CreditCardModel? cardModel;
  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        CameraScannerWidget(
          onNoCamera: () {
            ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
                content: Text('No camera found, please enable camera')));
          },
          onScan: (_, p1) {
            setState(() {
              cardModel = p1;
            });
          },
          loadingHolder: const Center(
            child: CircularProgressIndicator(),
          ),
        ),
        if (cardModel != null)
          Align(
            alignment: Alignment.bottomCenter,
            child: Container(
              decoration: BoxDecoration(
                  color: Colors.white, borderRadius: BorderRadius.circular(10)),
              padding: MediaQuery.of(context)
                  .padding
                  .add(const EdgeInsets.symmetric(horizontal: 10, vertical: 5)),
              child: AnimatedSwitcher(
                duration: const Duration(milliseconds: 400),
                child: Column(
                    mainAxisSize: MainAxisSize.min,
                    key: ValueKey(cardModel),
                    children: [
                      Text(cardModel!.number),
                      Text(cardModel!.holderName),
                      Text(cardModel!.expiryDate),
                    ]
                        .map((e) => Padding(
                            padding: const EdgeInsets.all(5),
                            child: Card(
                                child: Padding(
                              padding: const EdgeInsets.all(8.0),
                              child: e,
                            ))))
                        .toList()),
              ),
            ),
          )
      ],
    );
  }
}

Conclusion: Elevate your app's user experience with seamless credit card scanning! 🚀💳✨

所屬分類

依賴

依賴清單 4 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。