flutter_card_scanner_latest 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 75

Card Scanner Plugin

A Flutter plugin for iOS devices for scanning credit cards using the camera. If a device, doesn't support camera then a manual entry screen would be shown up where the caerd details can be entered.

This plugin uses the static CardIO library and is written in iOS native language i.e. Swift

Works on latest versions of Flutter, Dart & Swift.

This plugin works only for credit cards of type AMEX, JCB, VISA, MASTER CARD & DISCOVER.

Note: This plugin for Android is still under development, and some APIs might not be available yet.

Feedback and pull requests are welcome!

Installation:

  1. First, add flutter_card_scanner_latest as a dependency in your pubspec.yaml file.

  2. Add the following key to your Info.plist file, located in

    NSCameraUsageDescription - Camera in Use

Usage:

This is how one can invoke the plugin's method to start the scanning of credit cards.

Map<String, dynamic> details = await FlutterCardScannerLatest.scanCard();

Response:

{ "result":"success", "body":"{"Cardholders Name":"test","expiry":"01/21"}", "responseText":"Card has been scanned successfully" }

1.0.1 #

######Initial version of card scanner which supports only iOS devices.

1.0.2 #

######Added dartdoc comments.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:convert';
import 'package:flutter/services.dart';
import 'package:flutter_card_scanner_latest/flutter_card_scanner_latest.dart';
import 'CardScanResponse.dart';
import 'Constant.dart';

///Main class which demonstrates how to use the card scanner plugin.
void main() => runApp(MyApp());

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

class _MyAppState extends State<MyApp> {
  String cardScanResponse = '';

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initCardScan() async {
    String scanResponse='';
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      String response = await FlutterCardScannerLatest.scanCard;
      final CardScanResponse cardScanResponse =
      CardScanResponse.fromJSON(json.decode(response));
      if (cardScanResponse.result == Constant.success) {
        scanResponse = cardScanResponse.responseText +
            '\n' +
            'Cardholder\'s Name : ' +
            cardScanResponse.body.cardholderName + '\n' +
            'Expiry : ' +
            cardScanResponse.body.expiry;
      } else {
        scanResponse = cardScanResponse.responseText;
      }
    } on PlatformException catch (e) {
      scanResponse = "Failed to scan the card ::: '${e.message}'.";
    }

    setState(() {
      cardScanResponse = scanResponse;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
      appBar: AppBar(
        title: Text("Card Scanner"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            RichText(
              text: new TextSpan(
                style: new TextStyle(
                  fontSize: 20.0,
                  fontStyle: FontStyle.normal,
                  color: Colors.black,
                ),
                children: <TextSpan>[
                  new TextSpan(
                      text: cardScanResponse,
                      style: new TextStyle(fontWeight: FontWeight.bold)),
                ],
              ),
            ),
          ],
        ),
      ),
      floatingActionButtonLocation : FloatingActionButtonLocation.centerFloat,
      floatingActionButton: FloatingActionButton(
        onPressed: initCardScan,
        tooltip: 'Scan Card',
        elevation: 50.0,
        child: Icon(Icons.scanner),
      ),
    ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_card_scanner_latest: ^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:flutter_card_scanner_latest/flutter_card_scanner_latest.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
49
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]
75
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:flutter_card_scanner_latest/flutter_card_scanner_latest.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:flutter_card_scanner_latest/flutter_card_scanner_latest.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:flutter_card_scanner_latest/flutter_card_scanner_latest.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:flutter_card_scanner_latest/flutter_card_scanner_latest.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • flutter_card_scanner_latest that is a package requiring null.

Health suggestions

Format lib/flutter_card_scanner_latest.dart.

Run flutter format to format lib/flutter_card_scanner_latest.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test