Skip to content

Call out Text.rich constructor from RichText documentation #18433

Closed

Description

@alanrussian

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?

Activity

  1. alanrussian commented on Jun 13, 2018

    @alanrussian
    ContributorAuthor

    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.

  2. jonahwilliams commented on Jun 13, 2018

    @jonahwilliams
    Contributor

    What about using the Text.rich constructor?

  3. alanrussian commented on Jun 13, 2018

    @alanrussian
    ContributorAuthor

    I specifically need to use the multiple text span feature from RichText.

  4. jonahwilliams commented on Jun 13, 2018

    @jonahwilliams
    Contributor

    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.

  5. alanrussian commented on Jun 13, 2018

    @alanrussian
    ContributorAuthor

    Oh I see.

    Can someone add a pointer to that constructor in the RichText documentation?

  6. jonahwilliams commented on Jun 13, 2018

    @jonahwilliams
    Contributor

    Well, looking up and merging with any local styles can get expensive.

    Yes we should probably call that out explicitly

  7. alanrussian commented on Jun 13, 2018

    @alanrussian
    ContributorAuthor

    Great. Thanks!

  8. jonahwilliams commented on Jun 13, 2018

    @jonahwilliams
    Contributor

    I'm going to re-purpose this issue to a documentation bug then

  9. changed the title [-]Allow RichText to inherit from DefaultTextStyle[/-] [+]Call out Text.rich constructor from RichText documentation[/+] on Jun 13, 2018
  10. github-actions commented on Sep 3, 2021

    @github-actions

    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.

  11. locked as resolved and limited conversation to collaborators on Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

d: api docsIssues with https://api.flutter.dev/

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions