Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Switch widget color doesn't use ColorScheme #93709

Closed
@vbuberen

Description

@vbuberen

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

Metadata

Metadata

Assignees

Labels

f: material designflutter/packages/flutter/material repository.found in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions