SocialTextEditingController class

An improved TextEditingController for using with any widget that accepts TextEditingController. It uses SocialTextSpanBuilder for rendering the content. _detectionStream returns content of the current cursor position. Positions are calculated by the cyrrent location of the word Configuration is made by calling setter functions. example: _textEditingController = SocialTextEditingController() ..setTextStyle(DetectedType.mention, TextStyle(color: Colors.purple,backgroundColor: Colors.purple.withAlpha(50))) ..setTextStyle(DetectedType.url, TextStyle(color: Colors.blue, decoration: TextDecoration.underline)) ..setTextStyle(DetectedType.hashtag, TextStyle(color: Colors.blue, fontWeight: FontWeight.w600)) ..setRegexp(DetectedType.mention, Regexp("your_custom_regex_pattern");

There is also a helper function that can replaces range with the given value. In order to change cursor context, cursor moves to next word after replacement.

Inheritance

Properties

detectionTextStyles Map<DetectedType, TextStyle>
final
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
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-getteroverride-setter

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
getType(String word) DetectedType
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
replaceRange(String newValue, TextRange range) → void
setRegexp(DetectedType type, RegExp regExp) → void
setTextStyle(DetectedType type, TextStyle style) → void
subscribeToDetection(dynamic listener(SocialContentDetection detected)) StreamSubscription<SocialContentDetection>
toString() String
A string representation of this object.
inherited

Operators

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