isWideGrapheme function
Returns true if the given grapheme cluster is a double-width (wide) character.
Implementation
bool isWideGrapheme(String grapheme) {
if (grapheme.isEmpty) return false;
final codePoint = grapheme.runes.first;
// CJK Unified Ideographs & Extension A
if (codePoint >= 0x4E00 && codePoint <= 0x9FFF) return true;
if (codePoint >= 0x3400 && codePoint <= 0x4DBF) return true;
// Hangul Syllables
if (codePoint >= 0xAC00 && codePoint <= 0xD7AF) return true;
// CJK Symbols and Punctuation, Hiragana, Katakana, Hangul Compatibility Jamo, etc.
if (codePoint >= 0x3000 && codePoint <= 0x31FF) return true;
// Fullwidth Forms
if (codePoint >= 0xFF01 && codePoint <= 0xFF60) return true;
if (codePoint >= 0xFFE0 && codePoint <= 0xFFE6) return true;
// Emojis & Miscellaneous Symbols and Pictographs
if (codePoint >= 0x1F300 && codePoint <= 0x1F9FF) return true;
if (codePoint >= 0x1FA00 && codePoint <= 0x1FAFF) return true;
// CJK Unified Ideographs Extension B-F
if (codePoint >= 0x20000 && codePoint <= 0x2EBEF) return true;
// CJK Compatibility Ideographs
if (codePoint >= 0xF900 && codePoint <= 0xFAFF) return true;
// Additional CJK/Emoji ranges:
if (codePoint >= 0x1100 && codePoint <= 0x11FF) return true; // Hangul Jamo
if (codePoint >= 0x2E80 && codePoint <= 0x2FFF) {
return true; // CJK Radicals Supplement & Kangxi Radicals etc
}
if (codePoint >= 0x1F000 && codePoint <= 0x1F2FF) return true;
return false;
}