Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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
* `styleHighlights`: the default text style to the words to be highlighted
* `style`: the default text style
* `caseSensitive`: the case sensitive option

Expand Down Expand Up @@ -42,6 +43,11 @@ Widget buildDTH(String text, List<String> highlights) {
fontSize: 18.0,
fontStyle: FontStyle.italic,
),
styleHighlights: TextStyle(
color: Colors.redAccent,
fontSize: 18.0,
fontStyle: FontStyle.italic,
),
caseSensitive: false,
);
}
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.2.0"
version: "2.3.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down
9 changes: 6 additions & 3 deletions lib/dynamic_text_highlighting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class DynamicTextHighlighting extends StatelessWidget {
final List<String> highlights;
final Color color;
final TextStyle style;
final TextStyle styleHighlights;
final bool caseSensitive;

//RichText
Expand All @@ -32,6 +33,9 @@ class DynamicTextHighlighting extends StatelessWidget {
this.style = const TextStyle(
color: Colors.black,
),
this.styleHighlights = const TextStyle(
color: Colors.black,
),
this.caseSensitive = true,

//RichText
Expand Down Expand Up @@ -138,15 +142,14 @@ class DynamicTextHighlighting extends StatelessWidget {
if (style.color == null) {
return TextSpan(
text: value,
style: style.copyWith(
color: Colors.black,
style: styleHighlights.copyWith(
backgroundColor: color,
),
);
} else {
return TextSpan(
text: value,
style: style.copyWith(
style: styleHighlights.copyWith(
backgroundColor: color,
),
);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: dynamic_text_highlighting
description: Dynamic Text Highlighting (DTH) is a Flutter package written in pure Dart,
ideal for highlighting search results.
version: 2.2.0
version: 2.3.0
homepage: https://github.com/daniel-maxhari/dynamic_text_highlighting.git
repository: https://github.com/daniel-maxhari/dynamic_text_highlighting.git
issue_tracker: https://github.com/daniel-maxhari/dynamic_text_highlighting/issues
Expand Down