0

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?

shennan
  • 10,798
  • 5
  • 44
  • 79

2 Answers2

2

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.

shennan
  • 10,798
  • 5
  • 44
  • 79
  • Unfortunately, it is not solved yet on my flutter app. I have tried a **full restart** but divider color still black which is different than the `Theme.of(context).dividerColor`. – Kamran Ramzan Jan 26 '23 at 23:30
  • @KamranRamzan Likely that this is a separate issue. – shennan Jan 27 '23 at 11:35
  • Possibly, but i faced the similar problem and came to know that it was caused due to Material 3 adoption in flutter app. So I fixed it by supplying inline color to divider. – Kamran Ramzan Feb 06 '23 at 12:33
0

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,
)