Help with Flutter Theming

I followed a YouTube tutorial to see how to use a dropdown menu to select and save a theme using shared_preferences and it worked flawlessly actually, so i thought maybe i can use and implement the same code (almost same actually) to select the colorScheme and eventually this is what i came up with:
theme: ThemeData(colorScheme: provider.seedColor)
darkTheme: ThemeData(colorScheme: provider.seedColor)

but for the theming to stay working, i need to set the theme like this:

theme: ThemeData.light()
darkTheme: ThemeData.dark()

but this way the colorScheme won’t be set, so i use copyWith() this way:

theme: ThemeData.light().copyWith(colorScheme: provider.seedColor)
darkTheme: ThemeData.dark().copyWith(colorScheme: provider.seedColor)

but it’s not looking the same as if i was using the first method:

theme: ThemeData(colorScheme: provider.seedColor)
darkTheme: ThemeData(colorScheme: provider.seedColor)

now you might not understand much without looking at the code so here:

IMPORTANT NOTE: if you want to run the app, try creating the HomePage() class specified in the code and creating a button for the settings page.

Please help and hanks in advance!

but it’s not looking the same as if i was using the first method:
theme: ThemeData(colorScheme: provider.seedColor)
darkTheme: ThemeData(colorScheme: provider.seedColor)

Wdym exactly? ThemeData.dark.copyWith(colorScheme:provider.seedColor) is obviously different from ThemeData(colorScheme: provider.seedColor) so its expected that they would look different

  colorScheme: provider.seedColor,
  useMaterial3: true, // Ensure Material 3 is used
),
darkTheme: ThemeData(
  colorScheme: provider.seedColor,
  brightness: Brightness.dark, // Explicitly set brightness for dark mode
  useMaterial3: true,
),

For anyone reading this thread: this issue was resolved on GitHub!

flutter/flutter#162253

2 Likes