TypeSetEditingController class

A custom TextEditingController that provides WhatsApp-style text formatting capabilities in a text input field.

This controller extends the standard TextEditingController and overrides the buildTextSpan method to apply formatting to the text as it's being edited. It uses the TypesetParser to parse and format the text according to the formatting rules defined in the package.

Example usage:

final controller = TypeSetEditingController();
TextField(
  controller: controller,
  // Other TextField properties
);

The text can be formatted using the following syntax:

  • Bold: text
  • Italic: text
  • Strikethrough: text
  • Underline: #text#
  • Monospace: text
  • Link: §text|url§
  • Font size: text

The controller automatically renders the formatted text in the TextField while preserving the raw text with formatting markers for editing.

Inheritance

Constructors

TypeSetEditingController({String? text, TextStyle? linkStyle, GestureRecognizer linkRecognizerBuilder(String text, String url)?, TextStyle? monospaceStyle, TextStyle? boldStyle, Color markerColor = const Color(0xFF9E9E9E)})
Creates a controller for an editable text field with WhatsApp-style text formatting capabilities.

Properties

boldStyle TextStyle?
The style to apply to bold text.
final
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
linkRecognizerBuilder GestureRecognizer Function(String text, String url)?
A function that builds a gesture recognizer for links in the text.
final
linkStyle TextStyle?
The style to apply to links in the text.
final
markerColor Color
The color to use for formatting markers (like *, _, etc.)
final
monospaceStyle TextStyle?
The style to apply to monospace 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
text String
The current string the user is editing.
getter/setter pairinherited
value TextEditingValue
The current value stored in this notifier.
getter/setter pairinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
buildTextSpan({required BuildContext context, TextStyle? style, required bool withComposing}) 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
dispose() → void
Discards any resources used by the object.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited