simple_hashtag 0.1.0

SDKflutter
Platformandroidioswindowslinuxmacosweb

SimpleHashTag is a package that generates hashtags from strings.

Features

SimpleHashTag is a package that generates hashtags from strings.
By passing a string, a string starting with the specified trigger is hashtagged and returned as RichText.

Usage

You can use SimpleHashTag class to config text:

// Configure settings here
final _hashTag = SimpleHashTag();

For example.

// Configure settings here
final _hashTag = SimpleHashTag(textColor: Colors.red, hashTagColor: Colors.yellow);

The color of strings set as hashtags by the above settings will be yellow, and other strings will be red.
Currently available properties are as follows

namedescription
startTriggerSpecify the string that starts the tag. By default, [#] is set.
endTriggerSpecify the string that ends the tag. By default, [ ](half-width space) is set.
textColorNormal text color
hashTagColorColor of text to be hashtagged
textFontSizeNormal text size
hashTagFontSizeText size to be hashtagged

Set the text to be hashtagged as the first argument of the generateHashTag method and the callback when the hashtag is tapped as the second argument. RichText is returned as the return value, so it can be used as a widget as it is.


text = _hashTag.generateHashTag(
    controller.text,
        (hashTag) {
        // move to Specific tag page
         Navigator.push(
        context,
        MaterialPageRoute(
            builder: (context) => DetailPage(tag: hashTag),
            ),
        );
    },
);

https://user-images.githubusercontent.com/91307335/214048476-2d259b89-cf45-4695-9c3c-41030cb9e986.mov