Skip to content

Surface containers (and its variants) same color as surface #649

@YarosMallorca

Description

@YarosMallorca

Package

dynamic_color

Existing issue?

What happened?

When using Dynamic color, the surface container and its variants variants Theme.of(context).colorScheme.

  • surfaceContainer
  • surfaceContainerHighest
  • surfaceContainerHigh
  • surfaceContainerLow
  • surfaceContainerLowest

are the same color as Theme.of(context).colorScheme.surface.

Screenshot (web without dynamicColor, Android with dynamicColor:

Code:

import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return DynamicColorBuilder(
      builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) {
        return MaterialApp(
          debugShowCheckedModeBanner: false,
          theme: ThemeData(
            colorScheme:
                lightDynamic ?? ColorScheme.fromSeed(seedColor: Colors.cyan),
          ),
          darkTheme: ThemeData(
            colorScheme:
                darkDynamic ??
                ColorScheme.fromSeed(
                  seedColor: Colors.cyan,
                  brightness: Brightness.dark,
                ),
            brightness: Brightness.dark,
          ),
          themeMode: ThemeMode.dark,
          home: Scaffold(body: Center(child: MyWidget())),
        );
      },
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Card(
          child: Padding(
            padding: EdgeInsets.all(8),
            child: Text('Hello, World!'),
          ),
        ),
        Card(
          color: Theme.of(context).colorScheme.surfaceContainerHigh,
          child: Padding(
            padding: EdgeInsets.all(8),
            child: Text('Hello, World!'),
          ),
        ),
      ],
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp: dynamic_colortriageIssues that haven't been fully triaged (labels applied, reproducible bug / relevant feature request)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions