quickcapture 0.0.9 copy "quickcapture: ^0.0.9" to clipboard
quickcapture: ^0.0.9 copied to clipboard

PlatformAndroidiOS
outdated

An enterprise-grade Flutter plugin for document scanning and capture, compatible with Android and iOS. This plugin offers document scanning, AI-enhanced capture, identification, compression, optimizat [...]

example/lib/main.dart

import 'dart:convert';
import 'dart:io';

import 'package:flutter/material.dart';
import 'dart:async';
// Import the 'dart:io' library for File class.

import 'package:quickcapture/quickcapture.dart';
import 'package:open_file/open_file.dart';
// import 'package:url_launcher/url_launcher.dart';

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

typedef MyCallback = void Function(String result);

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

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

class _MyAppState extends State<MyApp> {
  final _quickcapturePlugin = Quickcapture();
  List<String> _capturedImage = [];

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

  Future<void> startCapture() async {
    String? response = await _quickcapturePlugin.startCapture();
    setState(() {
      // Assuming your JSON response is stored in the variable 'response'
      Map<String, dynamic> jsonResponse = jsonDecode(response!);
      // Extract the list of image paths from the 'fileCollection' key
      _capturedImage = List<String>.from(jsonResponse['fileCollection']);
    });
  }

  Future<void> buildPDF() async {
    String? response = await _quickcapturePlugin.buildPDFForLastCapture();
    if (response != null) {
      OpenFile.open(response);
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('QuickCapture'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              _capturedImage.isNotEmpty
                  ? Expanded(
                      child: ImageGrid(_capturedImage),
                    )
                  : Container(),
              ElevatedButton(
                onPressed: () => startCapture(),
                child: const Text("Start capture"),
              ),
              ElevatedButton(
                onPressed: () => buildPDF(),
                child: const Text("Build PDF"),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

class ImageGrid extends StatelessWidget {
  final List<String> imagePaths;

  const ImageGrid(this.imagePaths, {super.key});

  @override
  Widget build(BuildContext context) {
    return GridView.builder(
      gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 3, // Number of images per row
        crossAxisSpacing: 8.0,
        mainAxisSpacing: 8.0,
      ),
      itemCount: imagePaths.length,
      itemBuilder: (context, index) {
        return Image.file(
          File(imagePaths[index]),
          width: 200,
          height: 200,
          fit: BoxFit.cover,
        );
      },
    );
  }
}
16
likes
130
points
178
downloads

Publisher

verified publisherextrieve.com

Weekly Downloads

An enterprise-grade Flutter plugin for document scanning and capture, compatible with Android and iOS. This plugin offers document scanning, AI-enhanced capture, identification, compression, optimization, and conversion.Can control the DPI, layout, and size of the output images, which support JPEG, PDF, and TIFF formats.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on quickcapture

Packages that implement quickcapture