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

PlatformAndroidiOS
outdated

A new Flutter project.

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Plugin Image',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  File? _image;
  List? _output;

  ImagePicker picker = ImagePicker();

  // Func này lấy hình ảnh từ thư viện
  _pickImageFromGallery() async {
    PickedFile? pickedFile =
    await picker.getImage(source: ImageSource.gallery, imageQuality: 50);

    File image = File(pickedFile!.path);

    setState(() {
      _image = image;
    });

    await detect_image(_image!);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Image Picker"),
      ),
      body: SingleChildScrollView(
        child: Center(
          child: Container(
            padding: const EdgeInsets.all(16.0),
            child: Column(
              children: <Widget>[
                if (_image != null)
                  Image.file(_image!),
                RaisedButton(
                  onPressed: () {
                    _pickImageFromGallery();
                  },
                  child: Text("Select Image"),
                ),
                SizedBox(
                  height: 16.0,
                ),
                if (_output != null)
                  Text(
                    "${_output!}".toString(),
                    style: Theme.of(context).textTheme.headline3,
                  )
              ],
            ),
          ),
        ),
      ),
    );
  }

  Future<void> detect_image(File image) async {
    var output = ["99A-99999", "99A-66666"];

    setState(() {
      _output = output!;
    });
  }
}
0
likes
120
points
5
downloads

Publisher

unverified uploader

Weekly Downloads

A new Flutter project.

Homepage

Documentation

API reference

License

unknown (license)

Dependencies

flutter, image_picker

More

Packages that depend on ocr_image_plugin

Packages that implement ocr_image_plugin