Skip to content

Chips don't use the correct selected & unselected ColorScheme colors for the icons in Material 3 #136632

@TahaTesser

Description

@TahaTesser

Is there an existing issue for this?

Steps to reproduce

While working on other chip issues and testing the changes I noticed the chips aren't using the correct selected & unselected ColorScheme colors for the icons in Material 3.

According to tokens and the web specs, the chips should be using the onSurfaceVariant for the unselected state and onSecondaryContainer for selected state (for the chips that don't use primary color for the selected state)

"md.comp.filter-chip.with-leading-icon.disabled.leading-icon.color": "onSurface",
"md.comp.filter-chip.with-leading-icon.disabled.leading-icon.opacity": 0.38,
"md.comp.filter-chip.with-leading-icon.selected.dragged.leading-icon.color": "onSecondaryContainer",
"md.comp.filter-chip.with-leading-icon.selected.focus.leading-icon.color": "onSecondaryContainer",
"md.comp.filter-chip.with-leading-icon.selected.hover.leading-icon.color": "onSecondaryContainer",
"md.comp.filter-chip.with-leading-icon.selected.leading-icon.color": "onSecondaryContainer",
"md.comp.filter-chip.with-leading-icon.selected.pressed.leading-icon.color": "onSecondaryContainer",
"md.comp.filter-chip.with-leading-icon.unselected.dragged.leading-icon.color": "primary",
"md.comp.filter-chip.with-leading-icon.unselected.focus.leading-icon.color": "primary",
"md.comp.filter-chip.with-leading-icon.unselected.hover.leading-icon.color": "primary",
"md.comp.filter-chip.with-leading-icon.unselected.leading-icon.color": "primary",
"md.comp.filter-chip.with-leading-icon.unselected.pressed.leading-icon.color": "primary",
"md.comp.filter-chip.with-trailing-icon.disabled.trailing-icon.color": "onSurface",
"md.comp.filter-chip.with-trailing-icon.disabled.trailing-icon.opacity": 0.38,
"md.comp.filter-chip.with-trailing-icon.selected.dragged.trailing-icon.color": "onSecondaryContainer",
"md.comp.filter-chip.with-trailing-icon.selected.focus.trailing-icon.color": "onSecondaryContainer",
"md.comp.filter-chip.with-trailing-icon.selected.hover.trailing-icon.color": "onSecondaryContainer",
"md.comp.filter-chip.with-trailing-icon.selected.pressed.trailing-icon.color": "onSecondaryContainer",
"md.comp.filter-chip.with-trailing-icon.selected.trailing-icon.color": "onSecondaryContainer",
"md.comp.filter-chip.with-trailing-icon.unselected.dragged.trailing-icon.color": "onSurfaceVariant",
"md.comp.filter-chip.with-trailing-icon.unselected.focus.trailing-icon.color": "onSurfaceVariant",
"md.comp.filter-chip.with-trailing-icon.unselected.hover.trailing-icon.color": "onSurfaceVariant",
"md.comp.filter-chip.with-trailing-icon.unselected.pressed.trailing-icon.color": "onSurfaceVariant",
"md.comp.filter-chip.with-trailing-icon.unselected.trailing-icon.color": "onSurfaceVariant"

To reproduce run the code sample below which overrides these colors using a custom ColorScheme.

Expected results

Screenshot 2023-10-16 at 13 08 59

Actual results

Screenshot 2023-10-16 at 13 06 54

Code sample

Code sample
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.green).copyWith(
          onSurfaceVariant: const Color(0xffff0000),
          onSecondaryContainer: const Color(0xff0000ff),
        ),
      ),
      home: const Example(),
    );
  }
}

class Example extends StatefulWidget {
  const Example({super.key});

  @override
  State<Example> createState() => _ExampleState();
}

class _ExampleState extends State<Example> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            Column(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
                const Text('Selected'),
                FilterChip(
                    avatar: const Icon(Icons.favorite_rounded),
                    label: const Text('FilterChip'),
                    selected: true,
                    showCheckmark: false,
                    onSelected: (bool value) {}),
                InputChip(
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('InputChip'),
                  selected: true,
                  showCheckmark: false,
                  onPressed: () {},
                ),
                ChoiceChip(
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('ChoiceChip'),
                  selected: true,
                  showCheckmark: false,
                  onSelected: (bool value) {},
                ),
              ],
            ),
            Column(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
                const Text('Enabled'),
                FilterChip(
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('FilterChip'),
                  onSelected: (bool value) {},
                ),
                InputChip(
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('InputChip'),
                  onPressed: () {},
                ),
                ChoiceChip(
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('ChoiceChip'),
                  selected: false,
                  onSelected: (bool value) {},
                ),
              ],
            ),
            const Column(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
                Text('Disabled'),
                FilterChip(
                  avatar: Icon(Icons.favorite_rounded),
                  label: Text('FilterChip'),
                  onSelected: null,
                ),
                InputChip(
                  avatar: Icon(Icons.favorite_rounded),
                  label: Text('InputChip'),
                  isEnabled: false,
                  onPressed: null,
                ),
                ChoiceChip(
                  avatar: Icon(Icons.favorite_rounded),
                  label: Text('ChoiceChip'),
                  selected: false,
                  onSelected: null,
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel master, 3.16.0-11.0.pre.69, on macOS 14.0 23A344 darwin-arm64, locale en-US)
    • Flutter version 3.16.0-11.0.pre.69 on channel master at /Users/tahatesser/Code/flutter
    • Upstream repository [email protected]:TahaTesser/flutter.git
    • FLUTTER_GIT_URL = [email protected]:TahaTesser/flutter.git
    • Framework revision b66ab70c09 (4 hours ago), 2023-10-16 02:37:09 -0400
    • Engine revision 539ad5b232
    • Dart version 3.3.0 (build 3.3.0-27.0.dev)
    • DevTools version 2.28.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/tahatesser/Code/android-sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_SDK_ROOT = /Users/tahatesser/Code/android-sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A240d
    • CocoaPods version 1.13.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] VS Code (version 1.83.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.74.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 14.0 23A344 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 117.0.5938.149

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listf: material designflutter/packages/flutter/material repository.found in release: 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions