You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Call out Text.rich constructor from RichText documentation #18433
There are situations where I need to use the features of RichText, but I still want to inherit the DefaultTextStyle. The inability to inherit the text style makes it difficult to reuse components that specify their own DefaultTextStyle.
Would it be possible to add a bool parameter to inherit the text style?
I understand you can do this on a per span level. However, it would be more convenient to be able to do it on the entire widget level. There's already a way to specify the style on the per widget level.
You can pass child text spans pass it to the Text.rich constructor. I believe this should pass the default text style to the text spans in question.
new Text.rich(new TextSpan(children: <TextSpan>[...]))
The reason we have a Text widget is that looking up the text style from the context isn't free, and you could potentially have dozens and dozens of spans in view.
changed the title [-]Allow RichText to inherit from DefaultTextStyle[/-][+]Call out Text.rich constructor from RichText documentation[/+]on Jun 13, 2018
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
alanrussian commentedon Jun 13, 2018
I understand you can do this on a per span level. However, it would be more convenient to be able to do it on the entire widget level. There's already a way to specify the style on the per widget level.
jonahwilliams commentedon Jun 13, 2018
What about using the
Text.richconstructor?alanrussian commentedon Jun 13, 2018
I specifically need to use the multiple text span feature from
RichText.jonahwilliams commentedon Jun 13, 2018
You can pass child text spans pass it to the
Text.richconstructor. I believe this should pass the default text style to the text spans in question.new Text.rich(new TextSpan(children: <TextSpan>[...]))The reason we have a
Textwidget is that looking up the text style from the context isn't free, and you could potentially have dozens and dozens of spans in view.alanrussian commentedon Jun 13, 2018
Oh I see.
Can someone add a pointer to that constructor in the RichText documentation?
jonahwilliams commentedon Jun 13, 2018
Well, looking up and merging with any local styles can get expensive.
Yes we should probably call that out explicitly
alanrussian commentedon Jun 13, 2018
Great. Thanks!
jonahwilliams commentedon Jun 13, 2018
I'm going to re-purpose this issue to a documentation bug then
[-]Allow RichText to inherit from DefaultTextStyle[/-][+]Call out Text.rich constructor from RichText documentation[/+]github-actions commentedon Sep 3, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.