flutter_card_io 0.0.3 copy "flutter_card_io: ^0.0.3" to clipboard
flutter_card_io: ^0.0.3 copied to clipboard

Dart 1 only

CardIO plugin for flutter

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_card_io/flutter_card_io.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Map<String, dynamic> _data = {};

  @override
  initState() {
    super.initState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  _scanCard() async {
    Map<String, dynamic> details;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      details = await FlutterCardIo.scanCard({
        "requireExpiry": true,
        "scanExpiry": true,
        "requireCVV": true,
        "requirePostalCode": true,
        "restrictPostalCodeToNumericOnly": true,
        "requireCardHolderName": true,
        "scanInstructions": "Hola! Fit the card within the box",
      });

    } on PlatformException {
      print("Failed");
      return;
    }

    if (details == null) {
      print("Canceled");
      return;
    }

    if (!mounted) return;

    setState(() {
      _data = details;
    });
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('CardIO sample app'),
        ),
        body: new Column(
          children: <Widget>[
            new Column(
              children: _data.keys.map((String key) {
                return new Text(_data[key].toString());
              }).toList(),
            ),
            new Container(
              margin: new EdgeInsets.all(30.0),
              child: new Center(
                child: new RaisedButton(
                  child: new Text("Scan"),
                  onPressed: _scanCard,
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
0
likes
25
pub points
42%
popularity

Publisher

unverified uploader

CardIO plugin for flutter

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_card_io