hashtagable 0.1.2 copy "hashtagable: ^0.1.2" to clipboard
hashtagable: ^0.1.2 copied to clipboard

outdated

Widgets and functions to implement hashtag decorated text. Decorates the words which start with `#` like a Twitter.

hashtagable #

test pub package

Widgets and functions to implement hashTag decorated text.

Decorates the words start with # like a Twitter.

result

Usage #

  • As InputText

You can use HashTagEditableText to decorate input text.

    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),
      hintText: "Type Here"
    ),

decoratedStyle is the textStyle of tagged text. basicStyle is for untagged text.

  • As ReadOnlyText

If you want to decorate the text only to display, HashTagText will help you.

    HashTagText(
        text: "#Hello world. Hello #world",
        decoratedStyle: TextStyle(fontSize: 14,color:Colors.red),
        basicStyle: TextStyle(fontSize: 14,color:Colors.black),
        onTap: (text) {
          print(text);
        },
    )

The argument onTap(String) is called when user tapped a hashTag.

You can add some actions in this callback with the tapped hashTag.

Customize with some useful functions #

  • Check if the text has hashTags
   print(hasHashtags("Hello #World")); 
   // true
   
   print(hasHashtags("Hello World"));
   // false
   
  • Extract hashTags from text
   final List<String> hashTags = extractHashTags("#Hello World #Flutter Dart #Thank you");
   // ["#Hello", "#Flutter", "#Thank"]

Decoration rules #

The rules are almost same as twitter. It does not decorate the tags which contain emoji or symbol. It needs space before # to decorate.

134
likes
40
pub points
87%
popularity

Publisher

verified publisherbookm.me

Widgets and functions to implement hashtag decorated text. Decorates the words which start with `#` like a Twitter.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter, provider

More

Packages that depend on hashtagable