tesseract 0.0.8 copy "tesseract: ^0.0.8" to clipboard
tesseract: ^0.0.8 copied to clipboard

A flutter plugin for tesseract based on Android Tesseract and IOS SiwftyTesseract. It has unicode (UTF-8) support, and can recognize more than 100 languages.

example/lib/main.dart

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:tesseract/tesseract.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Tesseract Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Home(),
    );
  }
}

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Tesseract Demo'),
        centerTitle: true,
        // elevation: 0,
      ),
      body: SafeArea(
        child: Center(
          child: SingleChildScrollView(
            child: Padding(
              padding: EdgeInsets.symmetric(horizontal: 16),
              child: Column(
                children: [
                  //TODO Add Example

                  ElevatedButton(
                      onPressed: () {
                        initTesseract();
                      },
                      child: Text('Init Tesseract'))

                  // CustomCard(
                  //   label: 'Tesseract OCR',
                  //   featureStatus: FeatureStatus.Both,
                  //   viewPage: TesseractOCR(),
                  // ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }

  initTesseract() async {
    var result = await Tesseract.initTesseract(language: 'eng');
    print(result);
  }
}

class CustomCard extends StatelessWidget {
  final String label;
  final Widget viewPage;
  final FeatureStatus featureStatus;

  const CustomCard(
      {required this.label,
      required this.viewPage,
      required this.featureStatus});

  @override
  Widget build(BuildContext context) {
    return Card(
      elevation: 5,
      margin: EdgeInsets.only(bottom: 10),
      child: ListTile(
        tileColor: Theme.of(context).primaryColor,
        title: Text(
          label,
          style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
        ),
        onTap: () {
          if (Platform.isIOS &&
              (featureStatus.index == 0 || featureStatus.index == 1)) {
            ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                content: const Text(
                    'This feature has not been implemented for iOS yet')));
          } else if (Platform.isAndroid &&
              (featureStatus.index == 0 || featureStatus.index == 2)) {
            ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                content: const Text(
                    'This feature has not been implemented for Android yet')));
          } else if (!Platform.isAndroid && !Platform.isIOS) {
            ScaffoldMessenger.of(context).showSnackBar(
                SnackBar(content: const Text('Platform Not Supported')));
          } else
            Navigator.push(
                context, MaterialPageRoute(builder: (context) => viewPage));
        },
      ),
    );
  }
}

enum FeatureStatus { None, Android, IOS, Both }
2
likes
120
pub points
46%
popularity

Publisher

unverified uploader

A flutter plugin for tesseract based on Android Tesseract and IOS SiwftyTesseract. It has unicode (UTF-8) support, and can recognize more than 100 languages.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, path_provider

More

Packages that depend on tesseract