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

QuickCapture AI Based Mobile Document Scanning plugin for Flutter From Extrieve.

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();
    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,
        );
      },
    );
  }
}
12
likes
160
pub points
59%
popularity

Publisher

verified publisherextrieve.com

QuickCapture AI Based Mobile Document Scanning plugin for Flutter From Extrieve.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on quickcapture