highlight_text 0.5.0 copy "highlight_text: ^0.5.0" to clipboard
highlight_text: ^0.5.0 copied to clipboard

outdated

With this package you can highlight words and create specific styles and actions.

Highlight Text Plugin #

A flutter package to highlight words from a text.

Usage #

To use this package, add highlight_text as a dependency in your pubspec.yaml file.

Getting Started #

With this package you can highlight words and create specific actions for each highlighted word, you can customize the style of each word separately or create a unique style for all of them, you can also customize the style of the rest of the text.

Example #

Import the highlight library

import 'package:highlight_text/highlight_text.dart';

You should use the HighlightedWord class to specify the dictionary words in a Map object

Map<String, HighlightedWord> words = {
    "Flutter": HighlightedWord(
        onTap: () {
            print("Flutter");
        },
        textStyle: textStyle,
    ),
    "open-source": HighlightedWord(
        onTap: () {
            print("open-source");
        },
        textStyle: textStyle,
    ),
    "Android": HighlightedWord(
        onTap: () {
            print("Android");
        },
        textStyle: textStyle,
    ),
};

Now you can call the TextHighlight widget

TextHighlight(
    text: text, // You need to pass the string you want the highlights
    words: words, // Your dictionary words
    textStyle: TextStyle( // You can set the general style, like a Text()
        fontSize: 20.0,
        color: Colors.black,
    ),
    textAlign: TextAlign.justify, // You can use any attribute of the RichText widget
),
121
likes
0
pub points
96%
popularity

Publisher

verified publisherfeer.dev

With this package you can highlight words and create specific styles and actions.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on highlight_text