Skip to content

Bug: Switch.thumbIcon is given the wrong color and is unreadable #1065

Description

@adil192

When using a Material Switch with a thumb icon, the icon isn't colored correctly.

When the Switch is in its selected state, the icon becomes unreadable since it's white-on-white.

In the following screenshot, I've included the Yaru theme and the default ThemeData() Material theme:

Switch code snippet

This was put in example/lib/pages/theme_page/src/controls/toggleables.dart:

for (final theme in [null, ThemeData()])
  Theme(
    data: theme ?? Theme.of(context),
    child: Wrap(
      spacing: 10,
      children: [
        Switch(
          onChanged: (value) {},
          value: true,
          thumbIcon: WidgetStateProperty.all(
            const Icon(YaruIcons.ubuntu_logo),
          ),
        ),
        Switch(
          onChanged: (value) {},
          value: false,
          thumbIcon: WidgetStateProperty.all(
            const Icon(YaruIcons.ubuntu_logo),
          ),
        ),
        Switch(
          value: true,
          onChanged: null,
          thumbIcon: WidgetStateProperty.all(
            const Icon(YaruIcons.ubuntu_logo),
          ),
        ),
        Switch(
          value: false,
          onChanged: null,
          thumbIcon: WidgetStateProperty.all(
            const Icon(YaruIcons.ubuntu_logo),
          ),
        ),
        theme == null ? const Text('(Yaru)') : const Text('(Material)'),
      ],
    ),
  ),
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions