card_scanner 0.2.2 copy "card_scanner: ^0.2.2" to clipboard
card_scanner: ^0.2.2 copied to clipboard

Fast, Accurate and Secure Credit & Debit card scanning library for flutter.

example/lib/main.dart

import 'dart:math';

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

import 'package:card_scanner/card_scanner.dart';

void main() {
  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  CardDetails _cardDetails;
  CardScanOptions scanOptions = CardScanOptions(
    scanCardHolderName: true,
    // enableDebugLogs: true,
    validCardsToScanBeforeFinishingScan: 5,
    possibleCardHolderNamePositions: [
      CardHolderNameScanPosition.aboveCardNumber,
    ],
  );

  Future<void> scanCard() async {
    var cardDetails = await CardScanner.scanCard(scanOptions: scanOptions);
    if (!mounted) return;
    setState(() {
      _cardDetails = cardDetails;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('card_scanner app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: [
              RaisedButton(
                onPressed: () async {
                  scanCard();
                },
                child: Text('scan card'),
              ),
              Text('$_cardDetails'),
              Expanded(
                child: OptionConfigureWidget(
                  initialOptions: scanOptions,
                  onScanOptionChanged: (newOptions) => scanOptions = newOptions,
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
112
likes
40
points
93
downloads

Publisher

unverified uploader

Weekly Downloads

Fast, Accurate and Secure Credit & Debit card scanning library for flutter.

Repository (GitHub)
View/report issues

License

GPL-3.0 (license)

Dependencies

flutter

More

Packages that depend on card_scanner