Dynamic Text Highlighting (DTH) package for Dart & Flutter.

Overview

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;
  });
}
You might also like...

Flutter plugin for creating static & dynamic app shortcuts on the home screen.

Flutter plugin for creating static & dynamic app shortcuts on the home screen.

Flutter Shortcuts Show some ❤️ and ⭐ the repo Why use Flutter Shortcuts? Flutter Shortcuts Plugin is known for : Flutter Shortcuts Fast, performant &

Sep 26, 2022

Flutter plugin for creating static & dynamic app shortcuts on the home screen.

Flutter plugin for creating static & dynamic app shortcuts on the home screen.

Flutter Shortcuts Compatibility ✅ Android ❌ iOS (active issue: iOS support for quick actions) Show some ❤️ and ⭐ the repo Why use Flutter Shortcuts? F

Sep 26, 2022

Flutter Insert, Update, Delete and add form view dynamic

salesapp Insert, Update, Delete and form view add dynamic. Getting Started This project is a starting point for a Flutter application. A few resources

Dec 22, 2021

Flutter drawer (dynamic ready side menu)

Flutter drawer (dynamic ready side menu)

Flutter side menu (Drawer) Getting Started Use KFDrawer widget as Scaffold's body with items property (ListKFDrawerItem) you should define onPressed

Dec 5, 2022

Wallpaper App made with Flutter with Dynamic Theming.

Wallpaper App made with Flutter with Dynamic Theming.

Wallpaper App made with Flutter This is a wallpaper app made with flutter. This is just a UI demo. If you want to learn how to apply an image as wallp

Jan 2, 2023

Home app - A dynamic flutter app which can be used to generate alerts, set alarms and send sms or call someone

Home app - A dynamic flutter app which can be used to generate alerts, set alarms and send sms or call someone

first_app A dynamic flutter app which can be used to generate alerts, set alarms

Apr 9, 2022

A visualized dynamic programming for log collection based on flutter.

A visualized dynamic programming for log collection based on flutter. Pub使用 1. Depend on it Add this to your package's pubspec.yaml dependencies: mag

Nov 22, 2022

A Flutter plugin to use iOS 16.1+ Live Activities ⛹️ & iPhone 14 Pro Dynamic Island ⚫️ features

A Flutter plugin to use iOS 16.1+ Live Activities ⛹️ & iPhone 14 Pro Dynamic Island ⚫️ features

Live Activities A Flutter plugin to use iOS 16.1+ Live Activities & iPhone 14 Pro Dynamic Island features. 🧐 What is it ? This plugin use iOS Activit

Dec 26, 2022

Widget to count the amount of nested widget tree, useful in the dynamic construction of the interface when it is important to know the depth of widget.

Widget to count the amount of nested widget tree, useful in the dynamic construction of the interface when it is important to know the depth of widget.

widget_tree_depth_counter Widget Tree Depth Counter WidgetTreeDepthCounter is a simple widget to count the amount of nested widget tree, useful in the

Aug 1, 2022
Comments
  • Show all results when there is no search phrase

    Show all results when there is no search phrase

    Hi,

    I use this widget to show searching results but when searchbox is empty, I would like to show all data, not an empty list. Now I need to wrap my list item with this widget only when searching phrase is not empty.

    Can you do something to solve it?

    ps. Thanks for case sensitive option

    opened by mateusz0matti 1
  • combination with SelectableText.rich ?

    combination with SelectableText.rich ?

    Thanks for this great package it works very good!

    Would you please be so kind and tell me if there is any possibillity to combine this feature with a selectable Text in flutter? -> SelectableText.rich i did not figure a way out yet. If you have any clues on how to combine these to make all the text selectable, please let me know.

    Thanks again!

    opened by HolyMacarony 0
  • colors array attribute

    colors array attribute

    current pars: highlights: the words to be highlighted color: the highlight color

    can you update it to? highlights: const ['this', 'demo', 'will'], colors: [Colors.yellow,Colors.lightblue,Colors.lightgreen],

    Thanks a lot for your amazing work

    opened by JanRegent 0
  • No accent sensitive option

    No accent sensitive option

    Hi, There is no option to highlight a word with a accent if you search it without accent. For example for letter a there are a lot of variations like àáâã and it would be useful if you search a word without accent to be higlighted either way. I am working on a solution and i will send it.

    opened by craciunoctavian 1
Owner
null
Dynamic var - Dart dilinde dynamic ve var veri tiplerini anlamanızı kolaylaştıracak örnektir.

dynamic ve var arasındaki fark dynamic Tanımlanan değişkenin tipi daha sonra kod içerisinde değişebilir. Örneğin int olarak tanımlanan bir a değişkeni

Abdullah Sevmez 0 Jan 1, 2022
Syntax highlighting for Dart and Flutter

highlight.dart Syntax highlighting for Dart and Flutter, which supports lots of languages and themes. View gallery built with Flutter web Package Vers

GitTouch 181 Jan 8, 2023
Masked text field - A flutter package for masked text field for formet your text and good UI

Masked Text Field Masked Text Field Features A package for masked text field for

Alok Dubey 7 Sep 4, 2022
Text analyzer that extracts tokens from text for use in full-text search queries and indexes.

Tokenize text, compute document readbility and compare terms in Natural Language Processing. THIS PACKAGE IS PRE-RELEASE, and SUBJECT TO DAILY BREAKIN

GM Consult Pty Ltd 5 Dec 12, 2022
Grad text package - A Flutter Widget to draw gradients into text

grad_text A Flutter Widget to draw gradients into text.(Null safe) Demo Install

Karthik Sunil K 3 Jan 31, 2022
An Instagram like text editor Flutter widget that helps you to change your text style.

TextEditor An instagram like text editor widget for flutter Show some ❤️ and star the repo to support the project Features Edit TextStyle object font

Mehdi Zarepour 68 Dec 16, 2022
Detectable text field - Flutter Text widgets with detection features

detectable_text_field Text widgets with detection features. You can detect hasht

null 0 Feb 2, 2022
A text field that displays text on different languages based on your selection.

translatable_text_field A text field that displays text on different languages based on your selection. Its basic idea is that you place this fields i

null 0 Mar 13, 2022
Esizer - A Flutter package provide responsive, dynamic, configurable size for each device screen size

ESizer A Flutter package provide responsive, dynamic, configurable size for each

Extreme Vietnam Public 1 Feb 15, 2022
A dynamic, Stream-based API for job scheduling in Dart, capable of processing on different triggers.

Pendulum A library for task-scheduling in Dart. Exports a Task class that returns Streams, with a number of versatile options to customize how Tasks a

Aditya Kishore 1 Aug 22, 2020