myanmar_tools 0.0.2 copy "myanmar_tools: ^0.0.2" to clipboard
myanmar_tools: ^0.0.2 copied to clipboard

Myanmar Tools for Flutter. This Myanmar Tools library is ported from google myanmar-tools project(java)

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Myanmar Tools Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: const MyHomePage());
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final ZawGyiConverter converter = ZawGyiConverter();
  ZawGyiDetector? detector;
  String checkText = "";
  final _textController = TextEditingController();
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          SizedBox(
            width: 200,
            height: 80,
            child: TextField(
              textAlign: TextAlign.left,
              controller: _textController,
              decoration: const InputDecoration(
                hintText: 'Enter Something',
                contentPadding: EdgeInsets.all(20.0),
              ),
            ),
          ),
          SizedBox(
            width: 250,
            height: 50,
            child: Text(checkText),
          ),
          Row(
            children: [
              TextButton(
                onPressed: () {
                  _textController.text =
                      converter.zawGyiToUnicode(_textController.text);
                  setState(() {});
                },
                style: ButtonStyle(
                    backgroundColor:
                        MaterialStateProperty.all<Color>(Colors.blue),
                    foregroundColor:
                        MaterialStateProperty.all<Color>(Colors.white)),
                child: const Text('Convert to Unicode'),
              ),
              const SizedBox(
                width: 50,
              ),
              TextButton(
                onPressed: () {
                  _textController.text =
                      converter.unicodeToZawGyi(_textController.text);
                  setState(() {});
                },
                style: ButtonStyle(
                    backgroundColor:
                        MaterialStateProperty.all<Color>(Colors.blue),
                    foregroundColor:
                        MaterialStateProperty.all<Color>(Colors.white)),
                child: const Text('Convert to Zawgyi'),
              ),
              const SizedBox(
                width: 50,
              ),
              TextButton(
                onPressed: () async {
                  detector ??= await ZawGyiDetector.create();
                  var zawPossible =
                      detector!.getZawGyiProbability(_textController.text);
                  if (zawPossible == double.negativeInfinity) {
                    checkText = 'No Myanmar Text detected';
                  } else if (zawPossible < 0.05) {
                    checkText = 'Unicode Only';
                  } else {
                    checkText = 'Zawgyi';
                  }
                  setState(() {});
                },
                style: ButtonStyle(
                    backgroundColor:
                        MaterialStateProperty.all<Color>(Colors.blue),
                    foregroundColor:
                        MaterialStateProperty.all<Color>(Colors.white)),
                child: const Text('Check Zawgyi Probability'),
              ),
            ],
          )
        ],
      ),
    );
  }
}
3
likes
150
pub points
54%
popularity

Publisher

unverified uploader

Myanmar Tools for Flutter. This Myanmar Tools library is ported from google myanmar-tools project(java)

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on myanmar_tools