credit_card_field 1.0.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new61

credit_card_field #

pub package

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

screenshot

[1.0.0] - February 4, 2019

  • Added CreditCardFormField, CVVFormField, and ExpirationFormField

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

  • Updated description and README

example/main.dart

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.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Credit Card Form Field Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Credit Card Form Field Demo'),
    );
  }
}

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

  final String title;

  @override
  _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)),
    };
  }

  @override
  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>[
              CreditCardFormField(
                decoration: InputDecoration(
                  border: OutlineInputBorder(),
                  labelText: "Credit Card Number",
                ),
                controller: creditCardController,
              ),
              SizedBox(height: 8),
              CVVFormField(
                decoration: InputDecoration(
                  border: OutlineInputBorder(),
                  labelText: "CVV",
                ),
                controller: cvvController,
              ),
              SizedBox(height: 8),
              ExpirationFormField(
                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:


dependencies:
  credit_card_field: ^1.0.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages 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';
  
Version Uploaded Documentation Archive
1.0.2 Feb 5, 2019 Go to the documentation of credit_card_field 1.0.2 Download credit_card_field 1.0.2 archive
1.0.1 Feb 5, 2019 Go to the documentation of credit_card_field 1.0.1 Download credit_card_field 1.0.1 archive
1.0.0 Feb 5, 2019 Go to the documentation of credit_card_field 1.0.0 Download credit_card_field 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
23
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
61
Learn more about scoring.

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

  • Dart: 2.1.0
  • pana: 0.12.13
  • Flutter: 1.2.0

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

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