dynamic_text_highlighting 2.2.0 copy "dynamic_text_highlighting: ^2.2.0" to clipboard
dynamic_text_highlighting: ^2.2.0 copied to clipboard

Dynamic Text Highlighting (DTH) is a Flutter package written in pure Dart, ideal for highlighting search results.

Dynamic Text Highlighting (DTH) #

This package is used to highlight, in a completely dynamic way, keywords, or phrases, wherever they are present in a specified text.

demo

Getting Started #

DynamicTextHighlighting is also the name of the package widget. It returns a RichText widget and it accepts four basic parameters:

  • text: the whole text
  • highlights: the words to be highlighted
  • color: the highlight color
  • style: the default text style
  • caseSensitive: the case sensitive option

In addition to these parameters, there are others related to RichText widget:

  • TextAlign textAlign
  • TextDirection textDirection
  • bool softWrap
  • TextOverflow overflow
  • double textScaleFactor
  • int maxLines
  • Locale locale
  • StrutStyle strutStyle
  • TextWidthBasis textWidthBasis
  • TextHeightBehavior textHeightBehavior

Example #

Widget buildDTH(String text, List<String> highlights) {
  return DynamicTextHighlighting(
    text: text,
    highlights: highlights,
    color: Colors.yellow,
    style: TextStyle(
      fontSize: 18.0,
      fontStyle: FontStyle.italic,
    ),
    caseSensitive: false,
  );
}

It is a stateless widget, so for any changes just call setState(() {...}).

void applyChanges(List<String> newHighlights) {
  setState(() {
    highlights = newHighlights;
  });
}
54
likes
40
pub points
70%
popularity

Publisher

unverified uploader

Dynamic Text Highlighting (DTH) is a Flutter package written in pure Dart, ideal for highlighting search results.

Repository (GitHub)
View/report issues

License

Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on dynamic_text_highlighting