Flutter ETS API Documentation v1.0.0
Class: FlutterTextUtils
Utility class for text processing operations, including Unicode code point handling, emoji detection, and text offset calculations.
Constructors
Constructor
new FlutterTextUtils():
FlutterTextUtils
Returns
FlutterTextUtils
Methods
charCount()
staticcharCount(codePoint):number
Gets the number of UTF-16 code units required to represent a Unicode code point.
Parameters
codePoint
number
The Unicode code point
Returns
number
1 for BMP characters (0x0000-0xFFFF), 2 for supplementary characters (0x10000-0x10FFFF)
codePointAt()
staticcodePointAt(text,offset):number
Gets the Unicode code point at the specified offset in the text. Handles surrogate pairs correctly.
Parameters
text
string
The text to examine
offset
number
The offset position
Returns
number
The Unicode code point at the offset
Throws
RangeError if the offset is out of range
codePointBefore()
staticcodePointBefore(text,offset):number
Gets the Unicode code point before the specified offset in the text. Handles surrogate pairs correctly.
Parameters
text
string
The text to examine
offset
number
The offset position
Returns
number
The Unicode code point before the offset
Throws
RangeError if the offset is out of range
getImePreviewBackspaceDeleteRange()
staticgetImePreviewBackspaceDeleteRange(text,offset):ImePreviewBackspaceRange
One preview Backspace step: delete [delStart, delEnd) so a lone IME ' left of the caret
does not expand the removal to [delStart, caret) (which would swallow the previous letter too).
When [plain, offset) is apostrophe-only, deletes one grapheme cluster immediately before that run:
[getOffsetBefore(text, plain), plain) instead of […, offset).
Parameters
text
string
offset
number
Returns
getOffsetAfter()
staticgetOffsetAfter(text,offset):number
Gets the offset after the current position, handling complex Unicode sequences such as emojis, regional indicators, keycaps, and variation selectors.
Parameters
text
string
The text to examine
offset
number
The current offset position
Returns
number
The offset after the current position, accounting for Unicode sequences
getOffsetAfterForImePreview()
staticgetOffsetAfterForImePreview(text,offset):number
Same as getOffsetAfter, but if [offset, end) is only consecutive ' (IME separators),
extend once more so ' is not counted alone as one forward-delete step.
Parameters
text
string
offset
number
Returns
number
getOffsetBefore()
staticgetOffsetBefore(text,offset):number
Gets the offset before the current position, handling complex Unicode sequences such as emojis, regional indicators, keycaps, and variation selectors.
Parameters
text
string
The text to examine
offset
number
The current offset position
Returns
number
The offset before the current position, accounting for Unicode sequences
isEmoji()
staticisEmoji(code):boolean
Checks if a Unicode code point represents an emoji.
Parameters
code
number
The Unicode code point to check
Returns
boolean
True if the code point is an emoji, false otherwise
isEmojiModifier()
staticisEmojiModifier(code):boolean
Checks if a Unicode code point represents an emoji modifier.
Parameters
code
number
The Unicode code point to check
Returns
boolean
True if the code point is an emoji modifier, false otherwise
isEmojiModifierBase()
staticisEmojiModifierBase(code):boolean
Checks if a Unicode code point represents an emoji modifier base.
Parameters
code
number
The Unicode code point to check
Returns
boolean
True if the code point is an emoji modifier base, false otherwise
isKeycapBase()
staticisKeycapBase(code):boolean
Checks if a Unicode code point is a keycap base character (0-9, #, *).
Parameters
code
number
The Unicode code point to check
Returns
boolean
True if the code point is a keycap base, false otherwise
isRegionalIndicatorSymbol()
staticisRegionalIndicatorSymbol(code):boolean
Checks if a Unicode code point represents a regional indicator symbol.
Parameters
code
number
The Unicode code point to check
Returns
boolean
True if the code point is a regional indicator symbol, false otherwise
isTagSpecChar()
staticisTagSpecChar(code):boolean
Checks if a Unicode code point is a tag specification character.
Parameters
code
number
The Unicode code point to check
Returns
boolean
True if the code point is a tag specification character, false otherwise
isVariationSelector()
staticisVariationSelector(code):boolean
Checks if a Unicode code point represents a variation selector.
Parameters
code
number
The Unicode code point to check
Returns
boolean
True if the code point is a variation selector, false otherwise