CustomTextEditingController class
A variant of TextEditingController that decorates strings in an editable text field and enables tap, long-press and/or hover gestures based on flexible definitions.
This controller is useful for making partial strings in text such as URLs, email addresses or phone numbers clickable, or for only highlighting some parts of text with colors and different font settings depending on the types of text elements.
- Inheritance
-
- Object
- ChangeNotifier
- ValueNotifier<
TextEditingValue> - TextEditingController
- CustomTextEditingController
Constructors
-
CustomTextEditingController({String? text, required List<
TextDefinition> definitions, ParserOptions parserOptions = const ParserOptions(), TextStyle? style, TextStyle? matchStyle, TextStyle? tapStyle, TextStyle? hoverStyle, void onTap(GestureDetails)?, void onLongPress(GestureDetails)?, void onGesture(GestureDetails)?, Duration? longPressDuration, Duration? debounceDuration}) - Creates a controller for an editable text field.
-
CustomTextEditingController.fromValue(TextEditingValue? value, {required List<
TextDefinition> definitions, ParserOptions parserOptions = const ParserOptions(), TextStyle? style, TextStyle? matchStyle, TextStyle? tapStyle, TextStyle? hoverStyle, void onTap(GestureDetails)?, void onLongPress(GestureDetails)?, void onGesture(GestureDetails)?, Duration? longPressDuration, Duration? debounceDuration}) - Creates a controller for an editable text field from an initial TextEditingValue.
Properties
- debounceDuration ↔ Duration?
-
The debouncing duration after every text input action.
read / write
-
definitions
→ List<
TextDefinition> -
TextDefinition
s that specify rules for parsing, appearance and actions.final -
elements
→ List<
TextElement> -
The list of
TextElement
s as a result of parsing.read-only - hashCode → int
-
The hash code for this object.
read-onlyinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
read-onlyinherited
- hoverStyle → TextStyle?
-
The default text style used for matched strings while they are
under the mouse pointer.
final
- longPressDuration → Duration?
-
The duration before a tap is regarded as a long-press and the
onLongPress function is called.
final
- matchStyle → TextStyle?
-
The default text style for matched strings.
final
- onGesture → (void Function(GestureDetails)?)
-
The callback function called when a gesture happens on a text element.
final
- onLongPress → (void Function(GestureDetails)?)
-
The callback function called when a tappable element is long-pressed.
final
- onTap → (void Function(GestureDetails)?)
-
The callback function called when a tappable element is tapped.
final
- parserOptions → ParserOptions
-
The options for RegExp that configure how regular expressions
are treated.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
- selection ↔ TextSelection
-
The currently selected text.
read / writeinherited
- style → TextStyle?
-
The text style for strings that did not match any match patterns.
final
- tapStyle → TextStyle?
-
The default text style used for tappable strings while they are
being pressed.
final
- text ↔ String
-
The current string the user is editing.
read / writeinherited
- value ↔ TextEditingValue
-
The current value stored in this notifier.
read / writeinherited
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. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
override
-
isSelectionWithinTextBounds(
TextSelection selection) → bool -
Check that the
selection
is inside of the bounds of text.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