Go to file
Nathan Anderson 7ffeb2d199 dart analyzer 2023-12-07 16:24:17 -07:00
example 0.0.9 2023-12-07 15:37:29 -07:00
lib dart analyzer 2023-12-07 16:24:17 -07:00
readme_assets Updateto 0.0.4 2023-11-21 13:38:02 -07:00
test 0.0.6 release 2023-12-01 16:12:42 -07:00
.gitignore 0.0.3 released, see CHANGELOG.md 2023-11-21 09:45:25 -07:00
.metadata First commit, initialized library template 2023-11-08 15:42:09 -07:00
CHANGELOG.md 0.0.10 2023-12-07 16:23:11 -07:00
LICENSE 0.0.3 released, see CHANGELOG.md 2023-11-21 09:45:25 -07:00
README.md 0.0.6 release 2023-12-01 16:12:42 -07:00
analysis_options.yaml First commit, initialized library template 2023-11-08 15:42:09 -07:00
pubspec.yaml 0.0.10, remove that pesky Y 2023-12-07 16:03:02 -07:00


A simple and clean Stripe Element Card clone, rebuilt in native Flutter widgets.


This is not an officially maintained package by Stripe, but using the html stripe elements they provide in flutter was inconvenient for me, so I made this package.


Got to use emojis and taglines for attention grabbing and algorithm hacking:

  • Blazingly fast ( its as fast as the rest of flutter )
  • 🧹 Cleaner & Easier to Use ( fewer dependencies than the official stripe elements )
  • 🛡 Safe and Supports all Flutter Targets ( its native flutter with minimal dependencies )
  • ☑ Seemless UI/UX ( hard to match stripe quality, but I think I got pretty close )
  • 💳 Built-in Stripe Integration ( guess that one is obvious )
  • ☯ Chi Energy Boost ( alright I'm fishing... )

Why StripeNativeCardField?

  • Fewer dependencies: no more depending on Flutter Webview
  • Customizable: the entire field can inherit native Flutter styling, i.e. BoxDecoration()
  • Native Implementation: compiles and loads like the rest of your app, unlike embeded html
  • Automatic validation: no inputFormatters or RegExp needed on your side

The card data can either be retrieved with the onValidCardDetails callback, or you can have the element automatically create a Stripe card token when the fields are filled out, and return the token with the onTokenReceived callback.

Card Provider Detection

Card Provider Detection

Supported Card Providers in Docs

Customizable Styles

Customizable Style 1

This dark mode style example provided here

For documentation on all of the available customizable aspects of the CardTextField, go to the API docs here.

Smooth UX

Smooth UX

Mimics the Stripe html elements behavior wherever possible. Auto focusing / transitioning text fields, backspacing focuses to last field, automatically validating user input, etc.

Getting started

  • Install the package by running flutter pub add stripe_native_card_field


Include the package in a file:

import 'package:stripe_native_card_field/stripe_native_card_field.dart';

For Raw Card Data

Provide a callback for the CardTextField to return you the data when its complete.

  width: 500,
  onValidCardDetails: (details) {
    // Save the card details to use with your call to Stripe, or whoever
    setState(() => _cardDetails = details);

For Stripe Token

Simply provide a function for the onStripeResponse callback!

  width: 500,
  stripePublishableKey: 'pk_test_abc123', // Your stripe key here
  onStripeResponse: (Map<String, dynamic> data) {
    // Save the stripe token to send to your backend
    setState(() => _tokenData = data);

If you want more fine-grained control of when the stripe call is made, you can create a GlobalKey and access the CardTextFieldState, calling the getStripeResponse() function yourself. See the provided example for details. If you choose this route, do not provide an onStripeResponse callback, or you will end up making two calls to stripe!

Additional information

Repository located here

Please email me at n8r@fosscat.com for any issues or PRs.