vbuberen · GitHub

Looks like Switch widget still needs deprecated accentColor to be defined in ThemeData in order to not use the default color on Android. In my project I defined a whole ColorScheme to not use deprecated color values in ThemeData and saw that Switch ignores secondary defined in the app theme. I can only change color by adding accentColor property.

Attached a sample project with fully defined ColorScheme and Switch not following it.

This is how Switch looks with just ColorScheme defined:
Screenshot 2021-11-16 at 12 41 32

This is how Switch should look like and how it looks when I add accentColor to ThemeData:
Screenshot 2021-11-16 at 12 41 51

Steps to Reproduce

  1. Create new project
  2. Define full ColorScheme (with all defined colors)
  3. Add Switch widget and observe that it has the default Material blue color on Android.

Expected results: Switch follows secondary color as it is suggested in deprecation message for accentColor

Actual results: Switch has default Material blue color on Android

Code sample

bug.zip

flutter doctor output
// Attaching only Flutter related info, since other is irrelevant for the issue
[✓] Flutter (Channel stable, 2.5.3, on macOS 11.6.1 20G224 darwin-x64, locale en-UA)
    • Flutter version 2.5.3 at /Users/vb/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (5 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

Read the original on github.com ↗