Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/utpal-barman/u-credit-card-flutter

๐Ÿ’ณ "uCreditCard" is an Open Source Flutter package that offers a customizable solution for showing the UI of debit or credit cards within your app.
https://github.com/utpal-barman/u-credit-card-flutter

android card credit credit-card credit-card-design credit-card-flutter credit-card-ui creditcard dart debit-card debit-card-design flutter flutter-credit-card flutter-creditcard flutter-package flutter-ui flutter-widget ios

Last synced: about 1 month ago
JSON representation

๐Ÿ’ณ "uCreditCard" is an Open Source Flutter package that offers a customizable solution for showing the UI of debit or credit cards within your app.

Awesome Lists containing this project

README

        

# ๐Ÿ’ณ u_credit_card: ^1.4.0

## Credit Card UI as Flutter Widget ๐Ÿ’Ž

[![pub package](https://img.shields.io/pub/v/u_credit_card.svg?logo=dart&logoColor=00b9fc)](https://pub.dartlang.org/packages/u_credit_card)
[![Last Commits](https://img.shields.io/github/last-commit/utpal-barman/u-credit-card-flutter?logo=git&logoColor=white)](https://github.com/utpal-barman/u-credit-card-flutter/commits/main)
[![Pull Requests](https://img.shields.io/github/issues-pr/utpal-barman/u-credit-card-flutter?logo=github&logoColor=white)](https://github.com/utpal-barman/u-credit-card-flutter/pulls)
[![Code size](https://img.shields.io/github/languages/code-size/utpal-barman/u-credit-card-flutter?logo=github&logoColor=white)](https://github.com/utpal-barman/u-credit-card-flutter)
[![License](https://img.shields.io/github/license/utpal-barman/u-credit-card-flutter?logo=open-source-initiative&logoColor=green)](https://github.com/utpal-barman/u-credit-card-flutter/blob/main/LICENSE)

๐Ÿ”ฅ **u_credit_card** is a Flutter package for creating customizable and realistic-looking credit card UI with engaging animations. Elevate the visual appeal of your app and improve user interaction effortlessly!



## Resources ๐Ÿ“š

- [Documentation](https://pub.dev/documentation/u_credit_card/latest/u_credit_card/CreditCardUi-class.html)
- [Pub Package](https://pub.dev/packages/u_credit_card)
- [GitHub Repository](https://github.com/utpal-barman/u-credit-card-flutter)

## Installation ๐Ÿ’ป

1. **Add** `u_credit_card` to your `pubspec.yaml`:

```yaml
dependencies:
u_credit_card: ^1.4.0
```

2. **Install** the package:

```sh
flutter packages get
```

## Usage

To use the `CreditCardUi()` widget, import the package:

```dart
import 'package:u_credit_card/u_credit_card.dart';
```

Create a `CreditCardUi(...)` widget with the required parameters:

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

u_credit_card_basic_setup

---

## Parameters

| Name | Type | Description |
|-----------------------------|----------------------------|---------------------------------------------------------------------------------------------------------------------|
| `cardHolderFullName` | `String` | The cardholder's full name. **Required**. |
| `cardNumber` | `String` | The full credit card number. **Required**. |
| `validThru` | `String` | The expiration date in "MM/YY" format. **Required**. |
| `validFrom` | `String` | The "Valid From" date in "MM/YY" format. Optional. |
| `topLeftColor` | `Color` | Top-left gradient color. Defaults to `Colors.purple`. |
| `bottomRightColor` | `Color` | Bottom-right gradient color. Defaults to a darker shade of `topLeftColor`. |
| `doesSupportNfc` | `bool` | Displays NFC icon if set to `true`. Defaults to `true`. |
| `placeNfcIconAtTheEnd` | `bool` | Places NFC icon at the opposite side of the chip if set to `true`. Defaults to `false`. |
| `cardType` | `CardType` | Specifies card type. Defaults to `CardType.credit`. You can set it to `CardType.other` if you prefer not to specify a card type. This is optional. |
| `creditCardType` | `CreditCardType` | Specifies the credit card payment network logo. You can set it to `CreditCardType.none` if you prefer not to specify a card type and not show on the card UI. This is optional. |
| `cardProviderLogo` | `Widget` | Adds a provider logo. Optional. |
| `backgroundDecorationImage` | `DecorationImage` | Sets a background image. Optional. |
| `showValidThru` | `bool` | Toggles "Valid Thru" section. Defaults to `true`. |
| `currencySymbol` | `String` | Currency symbol. Defaults to `$`. |
| `balance` | `double` | Balance amount. Defaults to `0.0`. |
| `showBalance` | `bool` | Toggles the balance display. Defaults to `false`. |
| `enableFlipping` | `bool` | Enables card flipping. Defaults to `false`. |
| `autoHideBalance` | `bool` | Hides balance with a placeholder until tapped. Defaults to `false`. |
| `cvvNumber` | `String` | CVV number shown as `***`. |
| `disableHapticFeedBack` | `bool` | Disables haptic feedback on interactions. |
| `width` | `double` | Width of the card, up to a max of 300. |
| `shouldMaskCardNumber` | `bool` | Masks middle digits of the card number if set to `true`. Defaults to `true`. |

### Example

```dart
CreditCardUi(
cardHolderFullName: 'John Doe',
cardNumber: '1234567812345678',
validFrom: '01/23',
validThru: '01/28',
topLeftColor: Colors.blue,
),
```
u_credit_card_nfc_basic

By default, the card will have a chic blue gradient and an NFC icon. But don't worry, if you don't want the NFC icon, simply pass `doesSupportNfc: false`.

Want to switch things up and place the NFC icon on the opposite side of the chip? No problem! Just enable it by passing `placeNfcIconAtTheEnd: true`, but remember to also pass `doesSupportNfc: true`.

Let's make your app look as sleek as that shiny new credit card!

``` dart
CreditCardUi(
cardHolderFullName: 'John Doe',
cardNumber: '1234567812345678',
validFrom: '01/23',
validThru: '01/28',
topLeftColor: Colors.blue,
doesSupportNfc: true,
placeNfcIconAtTheEnd: true, // ๐Ÿ‘ˆ NFC icon will be at the end,
),
```

u_credit_card_nfc

#### Custom Gradient

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

This will create a credit card user interface with a red-to-purple gradient.

u_credit_card_gradient

#### Setting the card width

If you want to set the width of the card, use `width:` property.
Better NOT wrap with `SizedBox(width: ..., child: CreditCardUi(....))`, instead use `width:` right from the `CreditCardUi()`

``` dart
CreditCardUi(
width: 300, // ๐Ÿ‘ˆ this will set the width of the card
cardHolderFullName: 'John Doe',
cardNumber: '1234567812345678',
validThru: '10/24',
topLeftColor: Colors.red,
bottomRightColor: Colors.purpleAccent,
),
```

Note: Setting up any value more than 300 is not considered, maximum width can be 300 only.

#### Additional Customizations

To further customize the card, you can add a background image by using the `backgroundDecorationImage` property. Additionally, you can include a logo for the card provider using the `cardProviderLogo` property. This logo can be positioned on either the left or the right side of the card using the `cardProviderLogoPosition` property.

If you want to specify a particular card type to display, you can set it using the `cardType` property. If you prefer not to specify a card type, you can set `cardType: CardType.other`.

Here is an example of how to use these customization options:

Example:

``` dart
CreditCardUi(
cardHolderFullName: 'John Doe',
cardNumber: '1234567812345678',
validFrom: '01/23',
validThru: '01/28',
topLeftColor: Colors.blue,
doesSupportNfc: true,
placeNfcIconAtTheEnd: true,
cardType: CardType.debit,
cardProviderLogo: FlutterLogo(), // ๐Ÿ‘ˆ Set your logo here, supports any widget
cardProviderLogoPosition: CardProviderLogoPosition.right,
backgroundDecorationImage: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage( // ๐Ÿ‘ˆ `AssetImage` is also supported
'https://....',
),
),
),
```

Screenshot_2023-04-20_at_2 02 42_AM-removebg-preview

To display the balance of your card, simply set `showBalance: true` and provide the balance amount using `balance: 200.0` (any double value). Enabling `autoHideBalance: true` will generate a placeholder labeled "Tap to see balance". Users can then tap on this placeholder to reveal the balance.

```dart
CreditCardUi(
cardHolderFullName: 'John Doe',
cardNumber: '1234567812345678',
validFrom: '01/23',
validThru: '01/28',
topLeftColor: Colors.blue,
doesSupportNfc: true,
placeNfcIconAtTheEnd: true,
cardType: CardType.debit,
cardProviderLogo: FlutterLogo(),
cardProviderLogoPosition: CardProviderLogoPosition.right,
showBalance: true,
balance: 128.32434343,
autoHideBalance: true,
),
```

#### Card Flipping Animation

To enable the flipping animation by default, simply set the property `enableFlipping: true`. You can set CVV by `cvvNumber: 000`.

```dart
CreditCardUi(
cardHolderFullName: 'John Doe',
cardNumber: '1234567812345678',
validFrom: '01/23',
validThru: '01/28',
topLeftColor: Colors.blue,
doesSupportNfc: true,
placeNfcIconAtTheEnd: true,
cardType: CardType.debit,
cardProviderLogo: FlutterLogo(),
cardProviderLogoPosition: CardProviderLogoPosition.right,
showBalance: true,
balance: 128.32434343,
autoHideBalance: true,
enableFlipping: true, // ๐Ÿ‘ˆ Enables the flipping
cvvNumber: '123', // ๐Ÿ‘ˆ CVV number to be shown on the back of the card
),
```

เฆงเฆจเงเฆฏเฆฌเฆพเฆฆ

---

## Contributor


Utpal Barman
Utpal Barman ๐Ÿ‡ง๐Ÿ‡ฉ






Contact Author

## License

This package is released under the [BSD 3-Clause License](https://raw.githubusercontent.com/utpal-barman/u-credit-card-flutter/main/LICENSE).