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

Convert JPG to PDF, unlock, compress, merge, split & OCR PDFs with ScanPro.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:scanpro_dart/scanpro_dart.dart';
import 'package:scanpro_dart_example/examples/merge_pdf_example.dart';

import 'examples/ocr_example.dart';
import 'examples/pdf_conversion_example.dart';
import 'examples/pdf_security_example.dart';

void main() {
  // Initialize ScanPro with your API key
  ScanPro.initialize(apiKey: 'YOUR_API_KEY_HERE');

  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'ScanPro Flutter Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const HomePage(),
    );
  }
}

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

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('ScanPro Flutter Example'),
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
      ),
      body: Center(
        child: SingleChildScrollView(
          padding: const EdgeInsets.all(16.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              const Text(
                'ScanPro Flutter Plugin Examples',
                style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
                textAlign: TextAlign.center,
              ),
              const SizedBox(height: 40),
              _buildExampleButton(
                context,
                'PDF Conversion',
                'Convert PDFs to and from various formats',
                Icons.file_copy,
                Colors.blue,
                () => Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) => const PdfConversionExample(),
                  ),
                ),
              ),
              const SizedBox(height: 16),
              _buildExampleButton(
                context,
                'Merge PDFs',
                'Combine multiple PDF files into one',
                Icons.merge_type,
                Colors.green,
                () => Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) => const MergePdfExample(),
                  ),
                ),
              ),
              const SizedBox(height: 16),
              _buildExampleButton(
                context,
                'PDF Security',
                'Protect and unlock PDF documents',
                Icons.security,
                Colors.red,
                () => Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) => const PdfSecurityExample(),
                  ),
                ),
              ),
              const SizedBox(height: 16),
              _buildExampleButton(
                context,
                'OCR',
                'Extract text from images and PDFs',
                Icons.document_scanner,
                Colors.purple,
                () => Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) => const OcrExample()),
                ),
              ),
              const SizedBox(height: 40),
              const Text(
                'Note: Make sure to set your API key in main.dart before running the examples.',
                style: TextStyle(
                  fontStyle: FontStyle.italic,
                  color: Colors.red,
                ),
                textAlign: TextAlign.center,
              ),
            ],
          ),
        ),
      ),
    );
  }

  Widget _buildExampleButton(
    BuildContext context,
    String title,
    String description,
    IconData icon,
    Color color,
    VoidCallback onPressed,
  ) {
    return SizedBox(
      width: double.infinity,
      child: Card(
        elevation: 4,
        child: InkWell(
          onTap: onPressed,
          child: Padding(
            padding: const EdgeInsets.all(16.0),
            child: Row(
              children: [
                Container(
                  padding: const EdgeInsets.all(8.0),
                  decoration: BoxDecoration(
                    color: color.withOpacity(0.1),
                    borderRadius: BorderRadius.circular(8.0),
                  ),
                  child: Icon(icon, color: color, size: 32),
                ),
                const SizedBox(width: 16),
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(
                        title,
                        style: const TextStyle(
                          fontSize: 18,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                      const SizedBox(height: 4),
                      Text(
                        description,
                        style: TextStyle(color: Colors.grey[600]),
                      ),
                    ],
                  ),
                ),
                const Icon(Icons.arrow_forward_ios),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
2
likes
150
points
118
downloads

Publisher

verified publisherscanpro.cc

Weekly Downloads

Convert JPG to PDF, unlock, compress, merge, split & OCR PDFs with ScanPro.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_web_plugins, http, http_parser, mime, path, path_provider, plugin_platform_interface, web

More

Packages that depend on scanpro_dart