bimas_document_scanner 1.0.6 copy "bimas_document_scanner: ^1.0.6" to clipboard
bimas_document_scanner: ^1.0.6 copied to clipboard

Scan and crop automatically on iOS and Android with edge detection.

example/lib/main.dart

import 'dart:io';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:bimas_document_scanner/document_scanner.dart';
import 'package:bimas_document_scanner/ios_options.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

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

class _MyAppState extends State<MyApp> {
  List<String> _pictures = [];

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {}

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Document Scanner Example'),
        ),
        body: SingleChildScrollView(
            child: Column(
          children: [
            ElevatedButton(
                onPressed: onPressed, child: const Text("Add Pictures")),
            for (var picture in _pictures) Image.file(File(picture))
          ],
        )),
      ),
    );
  }

  void onPressed() async {
    List<String> pictures;
    try {
      pictures = await DocumentScanner.getPictures(
              noOfPages: 5,
              isGalleryImportAllowed: true,
              iosScannerOptions: const IosScannerOptions(
                imageFormat: IosImageFormat.jpg,
                jpgCompressionQuality: 0.5,
              ).toMap()) ??
          [];
      if (!mounted) return;
      setState(() {
        _pictures = pictures;
      });
    } catch (exception) {
      // Handle exception here
      print('Error: $exception');
    }
  }
}
0
likes
0
points
20
downloads

Publisher

unverified uploader

Weekly Downloads

Scan and crop automatically on iOS and Android with edge detection.

Homepage

License

unknown (license)

Dependencies

flutter, permission_handler, permission_handler_platform_interface, plugin_platform_interface

More

Packages that depend on bimas_document_scanner

Packages that implement bimas_document_scanner