RichTextController class Null safety

a custom controller based on TextEditingController used to activly style input text based on regex patterns and word matching with some custom features. {@tool snippet}

class _ExampleState extends State<Example> {

  late RichTextController _controller;

_controller = RichTextController(
      deleteOnBack: true,
      patternMatchMap: {
        //Returns every Hashtag with red color
        RegExp(r"\B#[a-zA-Z0-9]+\b"):
            const TextStyle(color: Colors.red, fontSize: 22.0),
        //Returns every Mention with blue color and bold style.
        RegExp(r"\B@[a-zA-Z0-9]+\b"): const TextStyle(
          fontWeight: FontWeight.w800,
          color: Colors.blue,
        ),

 TextFormField(
 controller: _controller,
 ...
)

{@end-tool}

Inheritance

Constructors

RichTextController({String? text, Map<RegExp, TextStyle>? patternMatchMap, Map<String, TextStyle>? stringMatchMap, required dynamic onMatch(List<String> match), bool? deleteOnBack = false})

Properties

deleteOnBack bool?
final
hashCode int
The hash code for this object.
read-only, inherited
hasListeners bool
Whether any listeners are currently registered.
@protected, read-only, inherited
onMatch → dynamic Function(List<String> match)
final
patternMatchMap Map<RegExp, TextStyle>?
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
selection TextSelection
The currently selected text.
read / write, inherited
stringMatchMap Map<String, TextStyle>?
final
text String
The current string the user is editing.
read / write, inherited
value TextEditingValue
The current value stored in this notifier.
read / write, inherited

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).
@mustCallSuper, inherited
isBack(String current, String last) bool
isSelectionWithinTextBounds(TextSelection selection) bool
Check that the selection is inside of the bounds of text.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
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