flutter_paycards 0.0.1 copy "flutter_paycards: ^0.0.1" to clipboard
flutter_paycards: ^0.0.1 copied to clipboard

outdated

Flutter plugin for PayCards SDK.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:flutter_paycards/flutter_paycards.dart';

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

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

class _MyAppState extends State<MyApp> {
  dynamic _cardScanResult;

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> scanCard() async {
    dynamic cardScanResult;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      cardScanResult = await FlutterPaycards.startRecognizer;
      debugPrint("cardScanResult $cardScanResult");
    } on PlatformException {
      debugPrint("PlatformException");
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _cardScanResult = cardScanResult;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('PayCards Plugin Example'),
        ),
        body: Container(
          alignment: Alignment.center,
          child: Padding(
            padding: EdgeInsets.all(10),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                Padding(
                  padding: EdgeInsets.only(bottom: 10),
                  child: RaisedButton(
                    onPressed: () {
                      scanCard();
                    },
                    child: Padding(
                        padding: EdgeInsets.all(10),
                        child: Text(
                          "Scan Card",
                          style: TextStyle(fontSize: 20),
                        )),
                  ),
                ),
                _cardScanResult != null
                    ? Column(
                        mainAxisSize: MainAxisSize.min,
                        children: <Widget>[
                          Text(
                            'Card Number: ${_cardScanResult['cardNumber']}',
                            style: TextStyle(fontSize: 20),
                          ),
                          Text(
                            'Card Holder Name: ${_cardScanResult['cardHolderName']}',
                            style: TextStyle(fontSize: 20),
                          ),
                          Text(
                            'Expiry Date: ${_cardScanResult['expiryMonth']}/${_cardScanResult['expiryYear']}',
                            style: TextStyle(fontSize: 20),
                          ),
                        ],
                      )
                    : Container(),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
6
likes
0
pub points
25%
popularity

Publisher

unverified uploader

Flutter plugin for PayCards SDK.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_paycards