Skip to content

[Proposal] Improve TabBarTheme styling API for indicator color #130392

@navaronbracke

Description

@navaronbracke

Is there an existing issue for this?

Use case

I had a use case where I wanted to style a TabBar using its TabBarTheme.

However, I noticed two issues with it:

  1. The indicatorColor is only taken from the TabBarTheme when using useMaterial3: true. When not using Material 3, it is using the to-be-deprecated ThemeData.indicatorColor. (I am aware that the transition to useMaterial3: true is imminent, but the flag will persist for a while after the fact still)
  2. The color of the labelStyle is ignored. Instead the labelColor property of the TabBar is used. This is mentioned in the docs, but if someone were to set TabBarThemeData.labelStyle.color, it feels weird that it does not apply.

Proposal

For the first issue, we could add a fallback to TabBarThemeData.indicatorColor regardless of the usage of Material 3.

final Color? indicatorColor = widget.indicatorColor ?? tabBarTheme.indicatorColor ?? theme.indicatorColor;

When ThemeData.indicatorColor is removed, we just remove it from here.

For the second issue, the problem is more subtle, but the solution should be straightforward.
The labelColor can be a MaterialStateColor. However, a MaterialStateColor is also a Color.

I'd propose that we deprecate the separate labelColor and that we use the labelStyle.color instead.

Related: #91772

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions