doc_scan_flutter 2.0.0 copy "doc_scan_flutter: ^2.0.0" to clipboard
doc_scan_flutter: ^2.0.0 copied to clipboard

A Flutter plugin for scanning documents with automatic edge detection, cropping, and enhancement. Uses ML Kit on Android and VisionKit on iOS for high-quality scans.

example/lib/main.dart

import 'package:doc_scan_flutter/doc_scan.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const DemoApp());
}

class DemoApp extends StatefulWidget {
  const DemoApp({super.key});

  @override
  State<DemoApp> createState() => _DemoAppState();
}

class _DemoAppState extends State<DemoApp> {
  DocScanFormat _format = .jpeg;
  List<String>? _scannedFiles;
  String? _errorMessage;

  Future<void> _scan() async {
    try {
      setState(() {
        _scannedFiles = null;
        _errorMessage = null;
      });

      final result = await DocumentScanner.scan(format: _format);
      setState(() => _scannedFiles = result);
    } on DocumentScannerException catch (e) {
      setState(() => _errorMessage = e.message);
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Doc Scan Flutter - Demo App')),
        body: Padding(
          padding: const .all(16),
          child: Column(
            crossAxisAlignment: .start,
            children: [
              Row(
                spacing: 24,
                children: [
                  Expanded(
                    child: DropdownButton<DocScanFormat>(
                      value: _format,
                      onChanged: (value) => setState(() => _format = value!),
                      items: const [
                        DropdownMenuItem(value: .jpeg, child: Text('JPEG')),
                        DropdownMenuItem(value: .pdf, child: Text('PDF')),
                      ],
                    ),
                  ),

                  ElevatedButton(onPressed: _scan, child: const Text('Scan')),
                ],
              ),

              const SizedBox(height: 20),

              if (_errorMessage != null)
                Text(
                  'Error: $_errorMessage',
                  style: const TextStyle(color: Colors.red),
                ),

              if (_scannedFiles != null) ...[
                const Text('Scanned files:'),
                ..._scannedFiles!.map(Text.new),
              ],

              const Spacer(),

              const Center(
                child: Column(
                  children: [
                    Text(
                      'Demo application, and library made with ❤️ by Ideeri',
                    ),
                    Text(
                      'github.com/Ideeri/doc_scan',
                      style: TextStyle(fontFamily: 'monospace'),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
12
likes
160
points
1.42k
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for scanning documents with automatic edge detection, cropping, and enhancement. Uses ML Kit on Android and VisionKit on iOS for high-quality scans.

Homepage
Repository (GitHub)
View/report issues

Topics

#document-scanner #pdf-scanner #flutter-plugin #visionkit #mlkit

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on doc_scan_flutter

Packages that implement doc_scan_flutter