Skip to content

ShadThemeData.copyWith has unexpected behavior #534

@Luckey-Elijah

Description

@Luckey-Elijah

Steps to reproduce

https://discord.com/channels/1218497173864452136/1437551614922723359

final ShadThemeData lightTheme = ShadThemeData(
  colorScheme: ShadColorScheme.fromName(name),
  brightness: Brightness.light,
);

Given this theme and I use a copyWith to generaste a "dark" theme

final ShadThemeData darkTheme = lightTheme.copyWith(
  colorScheme: ShadColorScheme.fromName(name, brightness: Brightness.dark),
  brightness: Brightness.dark,
);

I do not get the same results as creating a theme with the constructor

final ShadThemeData darkTheme = ShadThemeData(
  colorScheme: ShadColorScheme.fromName(name, brightness: Brightness.dark),
  brightness: Brightness.dark,
);

Expected results

Image

Actual results

lightTheme.copyWith(
colorScheme: ShadColorScheme.fromName(name, brightness: Brightness.dark),
brightness: Brightness.dark,
)

shadcn_ui version

0.39.3

Platform

MacOS

Code sample

Code sample
class App extends StatelessWidget {
  const App({super.key});

  @override
  Widget build(BuildContext context) {
    const name = 'yellow';
    final ShadThemeData lightTheme = ShadThemeData(
      colorScheme: ShadColorScheme.fromName(name),
      brightness: Brightness.light,
    );

    ShadThemeData darkTheme = ShadThemeData(
      colorScheme: ShadColorScheme.fromName(name, brightness: Brightness.dark),
      brightness: Brightness.dark,
    );

    // darkTheme = lightTheme.copyWith(
    //   colorScheme: ShadColorScheme.fromName(name, brightness: Brightness.dark),
    //   brightness: Brightness.dark,
    // );

    return ShadApp(
      theme: lightTheme,
      darkTheme: darkTheme,
      themeMode: ThemeMode.dark,
      home: Builder(
        builder: (context) {
          return Column(
            children: [
              ShadCard(
                title: const Text('Create new pouch'),
                description: const Text(
                  'A new pouch would be useful for a separate game or system you need to keep track.',
                ),
                trailing: ShadIconButton.outline(
                  icon: const Icon(LucideIcons.plus),
                  onPressed: () {},
                ),
              ),
            ],
          );
        },
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Metadata

Metadata

Labels

acceptedA valid and reproducible issuebugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions