Skip to content

Generated ColorScheme using colorSchemeSeed is different from ColorScheme.fromseed #107105

@raresvanca

Description

@raresvanca

// For surfaces that use primary color in light themes and surface color in dark
final Color primarySurfaceColor = isDark ? colorScheme.surface : colorScheme.primary;
final Color onPrimarySurfaceColor = isDark ? colorScheme.onSurface : colorScheme.onPrimary;
// Default some of the color settings to values from the color scheme
primaryColor = primarySurfaceColor;
primaryColorBrightness = ThemeData.estimateBrightnessForColor(primarySurfaceColor);
canvasColor ??= colorScheme.background;
accentColor ??= colorScheme.secondary;
accentColorBrightness ??= ThemeData.estimateBrightnessForColor(colorScheme.secondary);
scaffoldBackgroundColor ??= colorScheme.background;
bottomAppBarColor ??= colorScheme.surface;
cardColor ??= colorScheme.surface;
dividerColor ??= colorScheme.outline;
backgroundColor ??= colorScheme.background;
dialogBackgroundColor ??= colorScheme.background;
indicatorColor ??= onPrimarySurfaceColor;
errorColor ??= colorScheme.error;
applyElevationOverlayColor ??= brightness == Brightness.dark;

ThemeData gets some value defaults to the ones from a colors scheme only if it's made from a colorSchemeSeed, this creates a difference between specifying a ColorScheme.fromSeed() and just specifying a colorSchemeSeed.

For example:

theme: ThemeData(
              colorSchemeSeed: Colors.green,
              useMaterial3: true,
              brightness: Brightness.dark,
            ),

image

theme: ThemeData(
              colorScheme: ColorScheme.fromSeed(
                seedColor: Colors.green,
                brightness: Brightness.dark,
              ),
              useMaterial3: true,
            ),

image

Steps to Reproduce

  1. Create a material app and use both options

Expected results:
Expected that both variants produce the same result.

Actual results:
Using ColorScheme.fromSeed produces a different result not following M3 guidelines.

flutter doctor -v

[✓] Flutter (Channel master, 3.1.0-0.0.pre.1502, on Linux Mint 20.3 5.4.0-121-generic, locale en_US.UTF-8)
    • Flutter version 3.1.0-0.0.pre.1502 on channel master at /home/rares/.apps/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 363b0f1050 (9 hours ago), 2022-07-04 23:14:07 -0400
    • Engine revision 69901542b7
    • Dart version 2.18.0 (build 2.18.0-254.0.dev)
    • DevTools version 2.15.0

[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /home/rares/.apps/android-sdk/
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio (version 2021.1)
    • Android Studio at /home/rares/.apps/android-studio
    • Flutter plugin version 64.1.2
    • Dart plugin version 211.7798
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)

[✓] IntelliJ IDEA Community Edition (version 2022.1)
    • IntelliJ at /home/rares/.apps/idea-community
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin version 221.5591.58

[✓] VS Code (version 1.68.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.44.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Linux Mint 20.3 5.4.0-121-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 103.0.5060.114

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.


Metadata

Metadata

Assignees

Labels

f: material designflutter/packages/flutter/material repository.found in release: 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work on

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions