edge_detection_scan 0.0.1 copy "edge_detection_scan: ^0.0.1" to clipboard
edge_detection_scan: ^0.0.1 copied to clipboard

A cross-platform Flutter plugin that provides native document scanning with automatic edge detection, returning high-quality scanned image paths from both Android and iOS.

example/lib/main.dart

import 'dart:async';
import 'dart:io';

import 'package:edge_detection_scan/edge_detection_scan.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  final documentScannerPlugin = EdgeDetectionScan();

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      platformVersion =
          await documentScannerPlugin.getPlatformVersion() ??
          'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  List<String> scannedPaths = [];

  Future<void> scan() async {
    final result = await documentScannerPlugin.scanDocument();
    setState(() => scannedPaths = result);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Edge Detection Scan')),
        body: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text('Running on: $_platformVersion\n'),
              Expanded(
                child: ListView.builder(
                  itemCount: scannedPaths.length,
                  itemBuilder: (_, index) => Padding(
                    padding: const EdgeInsets.only(bottom: 8.0),
                    child: Image.file(File(scannedPaths[index]), height: 250),
                  ),
                ),
              ),
            ],
          ),
        ),
        floatingActionButton: FloatingActionButton.extended(
          onPressed: scan,
          label: Text('Scan'),
          icon: Icon(Icons.document_scanner_rounded),
        ),
      ),
    );
  }
}
5
likes
160
points
22
downloads

Publisher

unverified uploader

Weekly Downloads

A cross-platform Flutter plugin that provides native document scanning with automatic edge detection, returning high-quality scanned image paths from both Android and iOS.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on edge_detection_scan

Packages that implement edge_detection_scan