myanmar_kit 0.0.2
myanmar_kit: ^0.0.2 copied to clipboard
Myanmar-aware text widgets and utilities for Flutter.
myanmar_kit #
myanmar_kit is a Flutter package for apps that need to render, format, and
edit Myanmar text mixed with Latin text.
It focuses on:
- Myanmar-aware text sizing with
MMText - Selectable mixed-script text with
MMSelectableText - Grapheme-safe text utilities
- Heuristic Zawgyi detection and conversion
- Myanmar digit conversion, NRC formatting, and lightweight collation helpers
- A grapheme-safe text field wrapper
Why this package exists #
Myanmar text has a few practical problems in Flutter apps:
- Myanmar fonts often render visually taller than Latin fonts at the same size.
- Zawgyi text still appears in real-world data, even though it is not Unicode.
- Grapheme clusters should be treated atomically for editing and truncation.
- Myanmar text commonly omits spaces, which makes line breaking harder.
- Myanmar digits and NRC numbers need dedicated formatting helpers.
myanmar_kit packages those concerns into a small public API.
Installation #
dependencies:
myanmar_kit: ^0.0.1
Quick Start #
Set app-wide defaults with MMTextTheme in ThemeData.extensions:
MaterialApp(
theme: ThemeData(
extensions: [
MMTextTheme(
myanmarFont: 'Noto Sans Myanmar',
latinFont: 'Roboto',
minScale: 0.8,
maxScale: 1.0,
),
],
),
home: const HomePage(),
);
Use MMText instead of Text:
MMText(
text: 'Hello မြန်မာ',
style: const TextStyle(fontSize: 24),
)
Use MMTextField for Myanmar-safe editing:
MMTextField(
decoration: const InputDecoration(labelText: 'Myanmar text'),
)
Public API #
Text widgets #
MMTextMMText.richMMRichTextMMSelectableTextMMTextFieldMMTextConfigMMTextTheme
Encoding #
isLikelyZawgyizawgyiConfidencezawgyiToUnicodeunicodeToZawgyi
Text utilities #
graphemeLengthtoGraphemeClusterssafeTruncateinsertBreakHints
Formatting #
toMyanmarDigitstoArabicDigitscompareMyanmarisValidNrcformatNrc
Known limitations #
- Zawgyi detection is heuristic, not deterministic.
- Zawgyi conversion is a best-effort ordered mapping, not a full linguistic engine.
- The line-breaking helper inserts hints heuristically and is not ICU-grade.
- Myanmar collation here is lightweight and does not replace full ICU collation.
- Font-metric scaling depends on the requested fonts being loaded and available.
Example #
Run the example app in example/lib/main.dart to see side-by-side comparisons
and utility outputs.
