Skip to content

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

@drewwarren

Description

@drewwarren

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)

Metadata

Metadata

Assignees

Labels

d: api docsIssues with https://api.flutter.dev/f: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions