credit_card_field 1.0.2

credit_card_field #

pub package

Flutter credit card, cvv, and expiration form fields. Expiration form field is automatically formatted.


[1.0.0] - February 4, 2019

  • Added CreditCardFormField, CVVFormField, and ExpirationFormField

[1.0.1], [1.0.2] - February 4, 2019

  • Updated description and README


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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Credit Card Form Field Demo',
      theme: ThemeData(
      home: MyHomePage(title: 'Credit Card Form Field Demo'),

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  _MyHomePageState createState() => _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {

  TextEditingController creditCardController = TextEditingController();
  TextEditingController cvvController = TextEditingController();
  TextEditingController expirationController = TextEditingController();

  void _submit() {
    Map<String, dynamic> cardJson = {
      'number': creditCardController.text,
      'cvv': cvvController.text,
      'exp_month': int.tryParse(expirationController.text.substring(0, 2)),
      'exp_year': int.tryParse(expirationController.text.substring(3, 5)),

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Column(
            children: <Widget>[
                decoration: InputDecoration(
                  border: OutlineInputBorder(),
                  labelText: "Credit Card Number",
                controller: creditCardController,
              SizedBox(height: 8),
                decoration: InputDecoration(
                  border: OutlineInputBorder(),
                  labelText: "CVV",
                controller: cvvController,
              SizedBox(height: 8),
                decoration: InputDecoration(
                  border: OutlineInputBorder(),
                  labelText: "Card Expiration",
                  hintText: "MM/YY",
                controller: expirationController,
      floatingActionButton: FloatingActionButton(
        onPressed: _submit,
        tooltip: 'Submit',
        child: Icon(Icons.send),
      ), // This trailing comma makes auto-formatting nicer for build methods.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  credit_card_field: ^1.0.2

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:credit_card_field/credit_card_field.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 21, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Maintenance suggestions

Package is getting outdated. (-4.38 points)

The package was last published 54 weeks ago.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies