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

Best way to color text the secondary color of current theme? #3856

Closed
drewwarren opened this issue May 11, 2016 · 4 comments · Fixed by #31295
Closed

Best way to color text the secondary color of current theme? #3856

drewwarren opened this issue May 11, 2016 · 4 comments · Fixed by #31295
Assignees
Labels
d: api docs Issues with https://api.flutter.dev/ f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Comments

@drewwarren
Copy link

drewwarren commented May 11, 2016

Material design has a concept of a secondary text color: https://www.google.com/design/spec/style/color.html#color-text-background-colors

I can access this color in flutter using the very verbose: Theme.of(context).textTheme.caption.color. I don't want any of the extra styling (weight, fontSize) from from caption or display[1-4]. Using Colors.black54 directly is not ideal since it wouldn't adapt to theme changes. Is there a less verbose way for me to get the secondary text color of the current theme? Currently I made a package level function but it feels like there should be a better way:

Color secondary(BuildContext context) =>
  Theme.of(context).textTheme.caption.color;

This allows me to say

new TextStyle(color: secondary(context))

instead of

new TextStyle(color: Theme.of(context).textTheme.caption.color)
@eseidelGoogle eseidelGoogle added customer: fast (g3) f: material design flutter/packages/flutter/material repository. labels May 11, 2016
@abarth
Copy link
Contributor

abarth commented May 12, 2016

@Hixie Sounds like ThemeData should have a field for this.

@Hixie
Copy link
Contributor

Hixie commented May 13, 2016

Agreed.

@Hixie Hixie modified the milestone: Flutter 1.0 May 20, 2016
@Hixie Hixie modified the milestones: 4: Make shippers happy, 5: Make Hixie proud Jan 29, 2017
@Hixie Hixie added this to Specific documentation requests in Widget Documentation Apr 28, 2017
@Hixie Hixie added the framework flutter/packages/flutter repository. See also f: labels. label May 23, 2017
@Hixie
Copy link
Contributor

Hixie commented Oct 10, 2017

The secondary color is the accent color. There's a field on ThemeData for the accent color; we should point to it from the TextStyle docs or some such.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
d: api docs Issues with https://api.flutter.dev/ f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
Widget Documentation
Specific documentation requests
Development

Successfully merging a pull request may close this issue.

6 participants
@drewwarren @abarth @Hixie @eseidelGoogle @shihaohong and others