Skip to content
Open
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
25 changes: 17 additions & 8 deletions lib/substring_highlight.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class SubstringHighlight extends StatelessWidget {
),
this.wordDelimiters = ' .,;?!<>[]~`@#\$%^&*()+-=|\/_',
this.words =
false // default is to match substrings (hence the package name!)

false, // default is to match substrings (hence the package name!)
this.selectable = false
})
: assert(term != null || terms != null);

Expand Down Expand Up @@ -64,6 +64,9 @@ class SubstringHighlight extends StatelessWidget {

/// If true then match complete words only (instead of characters or substrings within words). This feature is in ALPHA... use 'words' AT YOUR OWN RISK!!!
final bool words;

/// If true then text is selectable
final bool selectable;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -158,11 +161,17 @@ class SubstringHighlight extends StatelessWidget {
}
}

return RichText(
maxLines: maxLines,
overflow: overflow,
text: TextSpan(children: children, style: textStyle),
textAlign: textAlign,
textScaleFactor: MediaQuery.of(context).textScaleFactor);
return selectable
? SelectableText.rich(TextSpan(children: children, style: textStyle),
maxLines: maxLines,
// overflow: overflow,
textAlign: textAlign,
textScaleFactor: MediaQuery.of(context).textScaleFactor)
: RichText(
maxLines: maxLines,
overflow: overflow,
text: TextSpan(children: children, style: textStyle),
textAlign: textAlign,
textScaleFactor: MediaQuery.of(context).textScaleFactor);
}
}