-
Notifications
You must be signed in to change notification settings - Fork 82
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
Add ReadMoreText.rich
constructor
#59
Conversation
@jonataslaw, Any ideas? Text layout measurement should work fine since annotations already create a custom final dataTextSpan = widget.richData ??
_buildAnnotatedTextSpan(
data: widget.data!,
textStyle: effectiveTextStyle,
regExp: regExp,
annotations: widget.annotations,
); |
ReadMoreText.rich
constructorReadMoreText.rich
constructor
The issue was with |
36be7f3
to
630764c
Compare
I need to check whether DefaultTextStyle is respected |
PR is ready for review |
2cdc0bf
to
3497ebf
Compare
effectiveTextStyle = defaultTextStyle.style.merge(widget.style); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a regression of #35 ?
I couldn't test to be sure if this brings back the problem, but we need to double check this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final defaultTextStyle = DefaultTextStyle.of(context);
var effectiveTextStyle = widget.style;
if (widget.style == null || widget.style!.inherit) {
effectiveTextStyle = defaultTextStyle.style.merge(widget.style);
}
The effectiveTextStyle
will never be null:
- If
widget.style
is null, theneffectiveTextStyle
will be equal todefaultTextStyle
. - If
widget.style
hasinherit
set to true,effectiveTextStyle
will be a merge ofdefaultTextStyle
andwidget.style
. - If
widget.style
hasinherit
set to false,effectiveTextStyle
will be set according towidget.style
and will not be overwritten bydefaultTextStyle
.
But I rewrote logic to make it more explicit:
final defaultTextStyle = DefaultTextStyle.of(context);
TextStyle effectiveTextStyle;
if (widget.style == null || widget.style!.inherit) {
effectiveTextStyle = defaultTextStyle.style.merge(widget.style);
} else {
effectiveTextStyle = widget.style!;
}
Wow, it is amazing! |
e51594f
to
ae854a4
Compare
LGTM |
closes #38
This PR enables the direct use of
TextSpan
instead of a plainString
. In this case, annotations won't be triggered since the developer has total control over styling and adding interactions to parts of the text.