Insurance Card Scanner

Our CardScanner Flutter widget makes it easy to add AI-powered insurance card scanning to any Flutter application in 5 minutes or less. Extract structured data from insurance cards using OCR, computer vision, and machine learning.

Compatibility

Android iOS
Support 5.0+ 12.0+

Installation

Add the insurance_card_scanner package to your pubspec.yaml file.

dependencies:
  flutter:
    sdk: flutter
  insurance_card_scanner: ^1.1.4

Or, run the following command:

flutter pub add insurance_card_scanner

Usage

Import the library widget into your project files:

import 'package:insurance_card_scanner/insurance_card_scanner.dart';

You can optionally add the API client for direct server communication:

import 'package:cardscan_client/cardscan_client.dart';

See the cardscan_client package for direct API integration.

For complete setup and usage documentation, refer to the Flutter package docs.

Getting started

Android camera permissions

Add the following line to your android/app/src/main/AndroidManifest.xml file:

<uses-permission android:name="android.permission.CAMERA" />

iOS camera permissions

Add the following lines to your ios/Runner/Info.plist file:

<key>NSCameraUsageDescription</key>
<string>This app needs camera access to scan insurance cards</string>
<key>NSAppTransportSecurity</key>
<dict>
 <key>NSAllowsArbitraryLoadsInWebContent</key>
   <true/>
 <key>NSAllowsLocalNetworking</key>
      <true/>
</dict>

Sandbox API Keys

Create a free account on the dashboard to generate a sandbox API key.

Basic examples

CardScanner widget

Use it on your custom screens like any other widget:

import 'package:insurance_card_scanner/insurance_card_scanner.dart';

class ScannerWidgetScreen extends StatelessWidget {
  const ScannerWidgetScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Scanner widget'),
      ),
      body: CardScanner(
        properties: CardScanConfig(
          sessionToken: 'your_session_token_here',
          onSuccess: (card) {
            debugPrint('Scan success: $card');
          },
          onError: (message) {
            debugPrint('Scan error: ${message ?? 'Unknown error'}');
          },
          onCancel: () {
            Navigator.of(context).pop();
          },
        ),
      ),
    );
  }
}

CardScannerModal widget

Push it using Navigator to open a full-screen scanner.


Navigator.of(context).push(
  CardScannerModal(
    properties: CardScanConfig(
      sessionToken: 'your_session_token_here',
      onSuccess: (card) {
        debugPrint('Scan success: $card');
      },
      onError: (message) {
        debugPrint('Scan error: ${message ?? 'Unknown error'}');
      },
      onCancel: () {
        Navigator.of(context).pop();
      },
    ),
  ),
);

Available Properties

Both CardScanner and CardScannerModal require a CardScanConfig instance with properties for server connection, callback handling, and UI customization.

CardScanConfig(
  // Required
  sessionToken: token,
  onSuccess: onSuccess,

  // Recommended
  onCancel: onCancel,
  onError: onError,
  live: live,

  // Optional
  backsideSupport: scanBackside,
  onRetry: onRetry,
  onWebViewLoadError: onWebViewLoadError,

  // UI Customization
  messages: messages,
  messageStyle: messagesStyle,
  autoSwitchActiveColor: autoSwitchActiveColor,
  autoSwitchInactiveColor: autoSwitchInactiveColor,
  progressBarColor: progressBarColor,
  widgetBackgroundColor: widgetBackgroundColor,
)

Authentication

CardScan supports authentication for two different use cases:

  • Server-to-server - Backend systems, admin portals, etc.
  • End User - Patient or clinician applications, typically on mobile or web

For detailed information on authentication and generating a JSON Web Token (JWT), see the authentication documentation.

Libraries

insurance_card_scanner
This library eases the process for obtaining insurance card's data.