0

I use package splash_screen_view for my splash screen. and it got the dark and light image for the default theme of the app. but if the user theme mobile is light and wants to use the app dark, how can I set a condition for my splash? the setting of this package sets In pubspec.yaml

so can anyone help me, please?

here is my pubspec: enter image description here

user17838882
  • 93
  • 2
  • 14
  • You can change the themeMode to light/dark inside the MaterialApp and save into preferences. This will always open the app in that particular mode and so the splash screen and app should run in the dark mode after restart. You can read about how to change it in [here](https://stackoverflow.com/questions/60232070/how-to-implement-dark-mode-and-light-mode-in-flutter) – A.H.M. Annur Apr 18 '22 at 09:18

1 Answers1

0

Check that your MaterialApp() has theme and darkTheme set AND set themeMode: ThemeMode.system, so your app follows the settings of the user's phone.

Looks something like this:

MaterialApp(
title: 'Great App',
theme: lightTheme, //create this
darkTheme: darkTheme, //create this
themeMode: ThemeMode.system, //follows user's device setting
home: GoHome(),
);

Your splashscreen will follow the correct setting.

Bonus: Search for flutter_native_splash to ALSO set the native splashcolor to phonesetting.

plotsklapps
  • 309
  • 1
  • 6