hashtagable 0.0.3
hashtagable: ^0.0.3 copied to clipboard
Widget and function to implement hashtag-decorated EditableText and RichText. Decorate the words which start with `#`
hashtagable #
Widget and function to implement hashtag-decorated EditableText and RichText.
It decorates the words start with #
Usage #
- As EditableText
If you want to decorate input text, HashTagEditableText
will help you.
HashTagEditableText(
controller: _textEditingController,
cursorColor: Theme.of(context).cursorColor,
basicStyle: TextStyle(fontSize: 14,color:Colors.black),
focusNode: FocusNode(),
onChanged: (_) {},
onSubmitted: (_) {},
decoratedStyle: TextStyle(fontSize: 14,color:Colors.red),
),
decoratedStyle
is the textStyle of tagged text. basicStyle
is the one of untagged text
- As RichText

If you want to decorate the text only to display, getHashTagTextSpan()
will help you.
All you need to do is just putting this function in RichText
.
RichText(
text: getHashTagTextSpan(
decoratedStyle: TextStyle(fontSize: 14,color:Colors.red),
basicStyle: TextStyle(fontSize: 14,color:Colors.black),
source: "#Hello world. Hello #world",
onTap: (text) {
print(text);
},
),
),
The argument onTap(String)
is called when user tapped tagged text.
Decoration rules #
The rules are almost same as twitter. It stop decorating if the tag contains emoji or symbol.
It needs space before #
to decorate.
