textdetect_widget 0.0.5 copy "textdetect_widget: ^0.0.5" to clipboard
textdetect_widget: ^0.0.5 copied to clipboard

outdated

A flutter plugin to integrate the Google MLKit for iOS and Android. Live Camera Text Detection is available on current version.

example/lib/main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:textdetect_widget/textdetect_widget.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  Map<String, String> companies;
  TextdetectController textdetectController;
  String tickerString;

  @override
  void initState() {
    super.initState();
    companies = <String, String>{
      "Tourism Holdings Limited": "THL.NZ",
      "Port of Tauranga Limited": "POT.NZ",
      "Metlifecare Limited": "MET.NZ",
    };
    for (int i=0;i<500;i++) {
      companies["$i"] = "$i";
    }
  }

  Future<dynamic> _handelTextDetect(MethodCall call) async {
    switch(call.method) {
      case "detect":
        debugPrint(call.arguments);
        setState(() {
          tickerString = call.arguments;
        });
        break;
      case "moveout":
        debugPrint(call.arguments);
        setState(() {
          tickerString = "Move out";
        });
        break;
      default:
        break;
    }
    return 0;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
            body: Stack(
              alignment: FractionalOffset.center,
              children: <Widget>[
                TextdetectWidget(
                  onTextDetectWidgetCreated: _onTextDetectCreated,
                  companies: companies,
                ),
                Text(
                  tickerString != null ? tickerString : '',
                  style: TextStyle(
                      color: Colors.red,
                      fontSize: 60.0
                  ),
                )
              ],
            )
        )
    );

  }

  void _onTextDetectCreated(TextdetectController controller) {
    textdetectController = controller;
    controller.setHandler(_handelTextDetect);
  }
}
2
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A flutter plugin to integrate the Google MLKit for iOS and Android. Live Camera Text Detection is available on current version.

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on textdetect_widget