shennan
shennan

Reputation: 11666

Using dividerColor in Theme does not result in coloured Dividers

I'm expecting that widgets in the display tree would be effected by a dividerColor having been set on my Theme in Flutter.

High up in my widget tree is:

MaterialApp(
  /* ... */
  theme: ThemeData(dividerColor: Colors.green)
  /* ... */
);

And yet when using a Divider() inside my child widgets, the colour is not present. Only when I set the colour explicitly, does it appear, like so:

Divider(color: Colors.green)

My understanding was that the Theme's dividerColor would be used when no colour is specified?

Upvotes: 5

Views: 3648

Answers (2)

Murali Krishna Regandla
Murali Krishna Regandla

Reputation: 1486

I faced this issue when I migrated my app to use Material 3.

I fixed it by adding the DividerTheme to my ThemeData object.

dividerTheme: const DividerThemeData(
  color: Colors.black12,
)

Upvotes: 9

shennan
shennan

Reputation: 11666

Apologies; I had not restarted the application... 🤦‍♂️

Posting answer here in case it helps anyone else; Theme changes need a full restart of the application as hot-reloading does not seem to have an affect when changing theme properties.

Upvotes: 2

Related Questions