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

u_credit_card 封面
套件詳情v1.6.0

u_credit_card

uCreditCard - 易於使用且美觀的卡片 UI Flutter 套件。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
3080
喜歡數
84
Pub 分數
160

安裝套件

flutter pub add u_credit_card

套件介紹

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

uCreditCard 是一個 Flutter 套件,提供易於使用且視覺效果出色的信用卡 UI 元件。專為尋求簡潔現代卡片介面的開發者設計,支援 Android、iOS、Web、macOS、Windows 和 Linux 等多個平台。該套件透過直覺的設計與無縫整合,提升使用者體驗,特別適用於支付或金融相關應用。它非常適合在 Flutter 應用中安全且美觀地顯示卡片資訊。

適用情境

  • 在應用中顯示信用卡細節
  • 建立付款表單介面
  • 建構金融或銀行應用程式
  • 提升結帳體驗
  • 設計安全的卡片輸入畫面

主要特色

  • 美觀且可自定義的卡片 UI
  • 跨平台相容性
  • 與 Flutter 的簡單整合
  • 支援多個作業系統
  • 適用於所有裝置的響應式設計

適合對象

  • Flutter 開發人員建構支付應用
  • 想要簡潔卡片組件的設計人員
  • 需要安全卡顯示的應用程式
  • 面向前端的金融工具
  • 基於卡片的介面快速原型設計

使用建議

  • 不包含完整的支付處理
  • 需要手動處理敏感資料
  • 僅限使用者介面;無掃描功能
  • 不適用於生產環境支付網關
  • 使用者必須實施額外的安全措施

原始 README

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

u_credit_card

A Flutter widget that renders a realistic, customizable credit-card UI with optional flip animation, balance display, and provider-logo support.

pub package Last Commits Pull Requests Code size License

u_credit_card preview

Contents

Features

  • Realistic card UI with chip, NFC indicator, gradient background, and OCR-A font for card numbers.
  • Automatic network detection for Visa, Mastercard, American Express, and Discover from the card number; can also be set explicitly or hidden.
  • Card types — credit, debit, prepaid, gift card, or none.
  • Flippable card — horizontal drag gesture flips between front and CVV-bearing back side; optional programmatic control via CreditCardController.
  • Balance display with optional "tap to reveal" mode (auto-hides after 2 seconds).
  • Customizable gradient colors, provider logo (any Widget), provider logo position, background image, card width, and card-number masking.
  • No third-party dependencies at runtime.

What it is / What it isn't

It is It isn't
A presentation-layer widget for displaying card details A card-number or CVV validator
Useful for wallets, dashboards, fintech mockups A payment-processing or tokenization library
Pure Dart + Flutter, no platform channels A PCI-compliant input form

If you need card-input form fields or Luhn validation as part of a payment flow, pair this widget with a dedicated forms or payments package.

Installation

Add the dependency to your pubspec.yaml:

dependencies:
  u_credit_card: ^1.6.0

Then fetch it:

flutter pub get

Import it where you need it:

import 'package:u_credit_card/u_credit_card.dart';

Quick start

The widget needs three values: cardholder name, card number, and the "Valid Thru" date.

CreditCardUi(
  cardHolderFullName: 'John Doe',
  cardNumber: '1234567812345678',
  validThru: '10/24',
)
u_credit_card_basic_setup

By default, the card is purple, shows the NFC icon next to the chip, and masks the middle digits of the card number.

Recipes

Each recipe builds on the quick-start example and shows only the parameters that change.

Custom gradient

Set topLeftColor and bottomRightColor to control the gradient. If you omit bottomRightColor, a darker shade of topLeftColor is used automatically.

CreditCardUi(
  cardHolderFullName: 'John Doe',
  cardNumber: '1234567812345678',
  validThru: '10/24',
  topLeftColor: Colors.red,
  bottomRightColor: Colors.purpleAccent,
)
u_credit_card_gradient

Because card text is rendered in white, avoid light gradient colors.

Sizing the card

Use the width parameter rather than wrapping the widget in a SizedBox. The card is laid out at its natural width of 300 logical pixels and scales proportionally to fit width. Values above 300 are clamped.

CreditCardUi(
  width: 240,
  cardHolderFullName: 'John Doe',
  cardNumber: '1234567812345678',
  validThru: '10/24',
)
Card type and network logo

cardType controls the small label at the top of the card (CREDIT, DEBIT, PREPAID, GIFT CARD); pass CardType.other to hide the label.

creditCardType controls the network logo (Visa, Mastercard, Amex, Discover). If omitted, the widget auto-detects the network from cardNumber. Pass CreditCardType.none to hide the logo entirely.

CreditCardUi(
  cardHolderFullName: 'John Doe',
  cardNumber: '4111111111111111',  // detected as Visa
  validThru: '10/24',
  cardType: CardType.debit,
  // creditCardType: CreditCardType.mastercard, // optional override
)
Provider logo and background image

cardProviderLogo accepts any widget — typically your bank or wallet logo. Position it on the left or right of the card-type label with cardProviderLogoPosition. Add a background image with backgroundDecorationImage; both NetworkImage and AssetImage are supported.

CreditCardUi(
  cardHolderFullName: 'John Doe',
  cardNumber: '1234567812345678',
  validThru: '10/24',
  cardProviderLogo: const FlutterLogo(),
  cardProviderLogoPosition: CardProviderLogoPosition.right,
  backgroundDecorationImage: const DecorationImage(
    fit: BoxFit.cover,
    image: NetworkImage('https://example.com/card-bg.png'),
  ),
)
u_credit_card_custom
Balance display

Set showBalance: true and pass a balance to render the amount in the top-left of the card. Enabling autoHideBalance: true replaces the figure with a "TAP TO SEE BALANCE" placeholder; tapping reveals it for two seconds. currencySymbol defaults to $.

CreditCardUi(
  cardHolderFullName: 'John Doe',
  cardNumber: '1234567812345678',
  validThru: '10/24',
  showBalance: true,
  balance: 128.32,
  autoHideBalance: true,
  currencySymbol: '€',
)
Flipping the card

Set enableFlipping: true to render a back side (with the CVV) and enable a horizontal-drag gesture that flips between sides. Provide the CVV with cvvNumber.

CreditCardUi(
  cardHolderFullName: 'John Doe',
  cardNumber: '1234567812345678',
  validThru: '10/24',
  enableFlipping: true,
  cvvNumber: '123',
)
u_credit_card flipping animation

Haptic feedback fires on each flip; disable it with disableHapticFeedBack: true.

Programmatic flipping API

For flows that need to flip the card in response to UI events — for example, flipping to the back when a CVV input field gains focus — attach a CreditCardController.

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

  @override
  State<CheckoutCard> createState() => _CheckoutCardState();
}

class _CheckoutCardState extends State<CheckoutCard> {
  final _cardController = CreditCardController();
  final _cvvFocusNode = FocusNode();

  @override
  void initState() {
    super.initState();
    _cvvFocusNode.addListener(() {
      if (_cvvFocusNode.hasFocus) {
        _cardController.flipToBack();
      } else {
        _cardController.flipToFront();
      }
    });
  }

  @override
  void dispose() {
    _cardController.dispose();
    _cvvFocusNode.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        CreditCardUi(
          controller: _cardController,
          enableFlipping: true,
          cardHolderFullName: 'John Doe',
          cardNumber: '1234567812345678',
          validThru: '10/24',
          cvvNumber: '123',
        ),
        TextField(
          focusNode: _cvvFocusNode,
          decoration: const InputDecoration(labelText: 'CVV'),
        ),
        ElevatedButton(
          onPressed: _cardController.flipCard,
          child: const Text('Flip'),
        ),
      ],
    );
  }
}

CreditCardController exposes:

Member Description
flipCard() Toggles between front and back.
flipToFront() Flips to the front; no-op if already on the front.
flipToBack() Flips to the back; no-op if already on the back.
isFlipped Getter — true when the back side is showing.

CreditCardController extends ChangeNotifier, so you can addListener to react to flip state changes. Call dispose() from your widget's dispose method.

The controller has no effect when enableFlipping: false. Pair the two parameters together.

Parameters reference

Listed alphabetically. Defaults reflect the constructor; null means "not provided".

Name Type Default Description
autoHideBalance bool? false Shows a "TAP TO SEE BALANCE" placeholder; tapping reveals the balance for 2 seconds.
backgroundDecorationImage DecorationImage? null Image painted under the gradient. Supports NetworkImage and AssetImage.
balance double? 0.0 Balance displayed when showBalance is true.
bottomRightColor Color? derived Bottom-right gradient stop. Defaults to a darker shade of topLeftColor.
cardHolderFullName String required Rendered uppercased on the front of the card.
cardNumber String required The card number. Spaces, dashes, and asterisks are normalized before display.
cardProviderLogo Widget? null Any widget — typically a bank or brand logo.
cardProviderLogoPosition CardProviderLogoPosition .right Position of cardProviderLogo relative to the card-type label.
cardType CardType .credit Drives the small label at the top of the card. CardType.other hides the label.
controller CreditCardController? null Drives programmatic flipping. Requires enableFlipping: true.
creditCardType CreditCardType? null Overrides the auto-detected network logo. Pass .none to hide it.
currencySymbol String? '$' Prefix shown before the balance.
cvvNumber String? '***' Shown on the back of the card when flipped.
disableHapticFeedBack bool? false Disables haptic feedback on flip and balance tap. (Note: the capital "B" reflects the existing public API.)
doesSupportNfc bool true Shows the NFC icon next to the chip.
enableFlipping bool? false Renders the back side and enables the drag-to-flip gesture. Required for controller to take effect.
placeNfcIconAtTheEnd bool false Moves the NFC icon to the opposite side of the chip. Has no effect when doesSupportNfc: false.
scale double 1.0 Deprecated — use width instead. Will be removed in a future minor release.
shouldMaskCardNumber bool true Masks the middle digits with *. Card numbers under 12 digits are never masked.
showBalance bool? false Shows the balance area in place of the card-type label.
showValidFrom bool true Shows the "VALID FROM" segment when validFrom is provided.
showValidThru bool true Shows the "VALID THRU" segment.
topLeftColor Color Colors.purple Top-left gradient stop.
validFrom String? null Optional "MM/YY" start date.
validThru String required "MM/YY" expiration date.
width double? null Maximum width in logical pixels. Capped at 300; smaller values scale the card proportionally.

Full API documentation is available on pub.dev.

Migration notes

  • scale → width (since 1.3.0). scale: 0.8 is equivalent to width: 240. The scale parameter will be removed in a future minor release.
  • disableShowingCardLogo removed (since 1.1.0). Use creditCardType: CreditCardType.none instead.
  • CreditCardController added in 1.6.0 for programmatic flipping. Existing widgets using only the drag gesture need no changes.

Compatibility

  • Flutter: 3.x (uses APIs available from Flutter 3.16+, e.g. Durations).
  • Dart: >=3.3.0 <4.0.0.
  • Platforms: any platform Flutter supports — no platform channels involved.

Contributing

Bug reports, feature requests, and pull requests are welcome. See CONTRIBUTING.md and the Code of Conduct.

For security-sensitive reports, follow the guidance in SECURITY.md.

License

Released under the BSD 3-Clause License.


Utpal Barman
Utpal Barman
Built with ♥ in Bangladesh — ধন্যবাদ

LinkedIn

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。