Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add softWrap support #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
7 changes: 7 additions & 0 deletions lib/substring_highlight.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class SubstringHighlight extends StatelessWidget {
{this.caseSensitive = false,
this.maxLines,
this.overflow = TextOverflow.clip,
this.softWrap = true,
this.term,
this.terms,
required this.text,
Expand All @@ -33,6 +34,11 @@ class SubstringHighlight extends StatelessWidget {
/// How visual overflow should be handled.
final TextOverflow overflow;

/// Whether the text should break at soft line breaks.
///
/// If false, the glyphs in the text will be positioned as if there was unlimited horizontal space.
final bool softWrap;

/// An optional maximum number of lines for the text to span, wrapping if necessary.
/// If the text exceeds the given number of lines, it will be truncated according
/// to [overflow].
Expand Down Expand Up @@ -161,6 +167,7 @@ class SubstringHighlight extends StatelessWidget {
return RichText(
maxLines: maxLines,
overflow: overflow,
softWrap: softWrap,
text: TextSpan(children: children, style: textStyle),
textAlign: textAlign,
textScaleFactor: MediaQuery.of(context).textScaleFactor);
Expand Down