document_capture

A Flutter package for scanning and capturing identity documents using the device camera.

Currently supports Kenya National ID cards (front and back), with planned support for passports and driver licenses.


โœจ Features

  • ๐Ÿ“„ Scan identity documents using camera
  • ๐Ÿ‡ฐ๐Ÿ‡ช Kenya National ID support (Front & Back)
  • ๐Ÿ“ท Real-time image capture
  • ๐Ÿ” Automatic document detection
  • ๐Ÿงพ MRZ (Machine Readable Zone) data extraction (Back of ID)
  • โšก Lightweight and easy to integrate

๐Ÿš€ Getting started

Add the package to your pubspec.yaml:

dependencies:
  document_capture: ^0.0.2

Then run:

flutter pub get

๐Ÿ“ฆ Usage

Import the package:

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:document_capture/widget/id_scan_button.dart';
import 'package:document_capture/mrz_parser/mrz_result.dart';

Example: Scanning ID (Front & Back)

class IdScanExample extends StatefulWidget {
  @override
  State<IdScanExample> createState() => _IdScanExampleState();
}

class _IdScanExampleState extends State<IdScanExample> {
  File? frontImage;
  File? backImage;
  File? faceImage;
  MRZContent? mrzContent;

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        // Scan Front of ID
        IdFrontScanButton(
          onCompleted: (result) {
            setState(() {
              frontImage = result['captureImage'] as File;
              faceImage = result['faceImage'] as File?;
            });
          },
          child: const Text('Scan Front of ID'),
        ),

        const SizedBox(height: 20),

        // Scan Back of ID
        IdBackScanButton(
          onCompleted: (result) {
            setState(() {
              backImage = result['fileImage'] as File;
              mrzContent = result['mrzContent'] as MRZContent;
            });
          },
          child: const Text('Scan Back of ID'),
        ),

        const SizedBox(height: 20),

        // Display extracted data
        if (mrzContent != null) ...[
          Text('Full Name: ${mrzContent!.fullNames}'),
          Text('ID Number: ${mrzContent!.personalNumber2}'),
          Text('Date of Birth: ${mrzContent!.birthDate}'),
          Text('Gender: ${mrzContent!.sex}'),
        ],
      ],
    );
  }
}

๐Ÿ“Œ Supported Documents

Document Type Status
Kenya National ID โœ… Supported
Passport ๐Ÿšง Planned
Driver License ๐Ÿšง Planned

๐Ÿ“Œ Use cases

  • KYC (Know Your Customer)
  • Fintech onboarding
  • Identity verification systems
  • Insurance and government applications

โš ๏ธ Requirements

  • Camera permission required
  • Works on Android and iOS

โš ๏ธ Limitations

  • Currently supports only Kenya National ID
  • Other document types are planned but not yet implemented

๐Ÿ”ฎ Roadmap

  • Passport scanning support
  • Driver license scanning
  • Multi-country document support
  • Improved OCR and data extraction

๐Ÿค Contributions

Contributions are welcome! Feel free to open issues or submit pull requests.


๐Ÿ“„ License

MIT License

Libraries

back_scanner/back_camera_overlay
back_scanner/back_camera_view
back_scanner/back_scan_controller
back_scanner/back_scanner
back_scanning_screen
camera/camera_screen
camera/camera_screen_two
camera/camera_viewer
camera/capture_button
camera_example
custom_face_detection/custom_vision_detector_visions/custom_camera_view
custom_face_detection/custom_vision_detector_visions/custom_face_detector_view
custom_face_detection/custom_vision_detector_visions/custom_painters/custom_coordinates_translator
custom_face_detection/custom_vision_detector_visions/custom_painters/custom_face_detector_painter
custom_face_detection/widgets/face_widget
document_capture
front_scanner/front_camera_overlay
front_scanner/front_camera_view
front_scanner/front_scan_controller
front_scanner/front_scanner
front_scanning_screen
id_guide_widget/digi_pass_widget
id_guide_widget/id_card_widgets
id_guide_widget/national_id_guide_widget
id_guide_widget/pointer_list_widget
main
model/id_scan_result
mrz_helper
mrz_parser/mrz_exceptions
mrz_parser/mrz_parser
mrz_parser/mrz_result
mrz_parser/td1_kenya_format_mrz_parser
painters/coordinates_translator
painters/face_detector_painter
scan
ui/widgets/test_widget
user_id_scan/add_id/kenya_back_screen
user_id_scan/add_id/kenya_front_screen
user_id_scan/add_id/kenya_id_screen
user_id_scan/add_id/model/user_id_model
user_id_scan/add_id/scan/ug_id_scanner
user_id_scan/add_id/scan_id_screens
user_id_scan/add_id/widgets/back_id_widgets
user_id_scan/add_id/widgets/id_widgets
user_id_scan/add_id/widgets/mrz_table
user_id_scan/add_id/widgets/national_id_card
user_id_scan/add_id/widgets/save_id_photos_btn
user_id_scan/identity_intro/id_guideline_screen
user_id_scan/identity_intro/kenya/national_id_guidelines
user_id_scan/scan/back_scanner/back_camera_overlay
user_id_scan/scan/back_scanner/back_camera_view
user_id_scan/scan/back_scanner/back_scan_controller
user_id_scan/scan/back_scanner/back_scanner
user_id_scan/scan/back_scanning_screen
user_id_scan/scan/front_scanner/front_alt_camera_view
user_id_scan/scan/front_scanner/front_alt_scanner
user_id_scan/scan/front_scanner/front_alt_scanning_screen
user_id_scan/scan/front_scanner/front_camera_overlay
user_id_scan/scan/front_scanner/front_camera_view
user_id_scan/scan/front_scanner/front_scan_controller
user_id_scan/scan/front_scanner/front_scanner
user_id_scan/scan/front_scanning_screen
user_id_scan/scan/mrz_helper
user_id_scan/scan/mrz_parser/mrz_checkdigit_calculator
user_id_scan/scan/mrz_parser/mrz_exceptions
user_id_scan/scan/mrz_parser/mrz_field_parser
user_id_scan/scan/mrz_parser/mrz_field_recognition_defects_fixer
user_id_scan/scan/mrz_parser/mrz_parser
user_id_scan/scan/mrz_parser/mrz_result
user_id_scan/scan/mrz_parser/mrz_string_extensions
user_id_scan/scan/mrz_parser/td1_format_mrz_parser
user_id_scan/scan/mrz_parser/td1_kenya_format_mrz_parser
user_id_scan/scan/mrz_parser/td2_format_mrz_parser
user_id_scan/scan/mrz_parser/td3_format_mrz_parser
user_id_scan/scan/painters/coordinates_translator
user_id_scan/scan/painters/face_detector_painter
user_id_scan/scan/widget/scanner_widget
user_id_scan/ui/screens/user_id_scan_screen
util/date_formatting
util/util
widget/id_scan_button
widget/scanner_widget