URichTextController class
A TextEditingController that keeps a list of UStyleSpans in sync with text edits and renders them via buildTextSpan. It survives insertions/deletions by shifting spans and exposes helpers to toggle/apply formatting on the current selection.
- Inheritance
-
- Object
- ChangeNotifier
- ValueNotifier<
TextEditingValue> - TextEditingController
- URichTextController
- Available extensions
Constructors
-
URichTextController({String? text, List<
UStyleSpan> ? spans})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
-
pending
→ Map<
UInlineAttr, Object?> -
Formatting queued for the next typed character while the selection is
collapsed (so pressing bold then typing produces bold text).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selection ↔ TextSelection
-
The currently selected range within text.
getter/setter pairinherited
-
spans
→ List<
UStyleSpan> -
final
- text ↔ String
-
The current string the user is editing.
getter/setter pairinherited
- value ↔ TextEditingValue
-
The current value stored in this notifier.
getter/setter pairinherited-getteroverride-setter
Methods
-
activeAttributes(
) → Set< UInlineAttr> - The active boolean attributes covering the whole current selection.
-
activeLink(
) → String? - The href active at the current selection, or null.
-
activeValue(
UInlineAttr attr) → Object? - The value of a value-attribute at the current selection, or null when the selection is not uniformly covered by it.
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
applyValue(
UInlineAttr attr, Object? value) → void -
Apply (or clear when
valueis null) a value-attribute over the selection. -
buildTextSpan(
{required BuildContext context, required bool withComposing, TextStyle? style}) → TextSpan -
Builds TextSpan from current editing value.
override
-
clear(
) → void -
Set the value to empty.
inherited
-
clearComposing(
) → void -
Set the composing region to an empty range.
inherited
-
clearFormatting(
) → void - Remove every inline attribute over the current selection.
-
dispose(
) → void -
Discards any resources used by the object.
inherited
-
isNotNullOrEmpty(
) → bool -
Available on TextEditingController, provided by the TextEditingControllerExtension extension
-
isNullOrEmpty(
) → bool -
Available on TextEditingController, provided by the TextEditingControllerExtension extension
-
normalize(
) → void - Merge touching/overlapping spans that share attr + value.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
numDouble(
) → double -
Available on TextEditingController, provided by the TextEditingControllerExtension extension
-
numInt(
) → int -
Available on TextEditingController, provided by the TextEditingControllerExtension extension
-
numString(
) → String -
Available on TextEditingController, provided by the TextEditingControllerExtension extension
-
onBeforeTextChange(
String oldText, String newText) → void - Optional hook so subclasses can react to text edits before spans shift.
-
removeAttr(
UInlineAttr attr, int s, int e) → void -
Subtract the range [s, e) from every span of
attr, splitting as needed. -
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
setContent(
String newText, List< UStyleSpan> newSpans, {int? caret}) → void - Replace the whole styled content in one shot.
-
snapshotSpans(
) → List< UStyleSpan> - A deep copy of the current spans, for undo snapshots.
-
styleAt(
int i, TextStyle base, ColorScheme cs) → TextStyle -
The resolved TextStyle for the character at index
i. -
toggleAttribute(
UInlineAttr attr) → void - Toggle a boolean attribute over the current selection. With a collapsed selection the attribute is queued for the next typed characters.
-
toString(
) → String -
A string representation of this object.
inherited
-
trimmedLatin(
) → String -
Available on TextEditingController, provided by the TextEditingControllerExtension extension
-
valueOrNull(
) → String? -
Available on TextEditingController, provided by the TextEditingControllerExtension extension
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
mapOffsetEnd(
int x, int prefix, int removedEnd, int delta) → int - Remaps a range end across the same edit as mapOffsetStart.
-
mapOffsetStart(
int x, int prefix, int removedEnd, int delta) → int -
Remaps a range start across an edit that replaced
[prefix, removedEnd)with a region of lengthremovedEnd - prefix + delta. -
resolveStyle(
Map< UInlineAttr, Object?> active, TextStyle base, ColorScheme cs) → TextStyle -
Turns a map of active attributes into a TextStyle on top of
base.