copyTheme static method
Implementation
static ThemeData copyTheme(Color themeColor,
{Color? appBarColor, bool centerTitle = true, bool isDarkMode = false, bool useMaterial3 = false}) {
return (isDarkMode ? ThemeData.dark(useMaterial3: useMaterial3) : ThemeData.light(useMaterial3: useMaterial3))
.copyWith(
primaryColor: themeColor,
//默认的主题色
// primaryColorBrightness: isDarkMode ? Brightness.dark : Brightness.light,
elevatedButtonTheme: ElevatedButtonThemeData(
style: ButtonStyle(backgroundColor: MaterialStateProperty.all<Color>(themeColor)),
),
colorScheme: isDarkMode
? ColorScheme.dark(
secondary: themeColor,
primary: themeColor,
onSecondary: themeColor,
)
: ColorScheme.light(
secondary: themeColor,
primary: themeColor,
onSecondary: themeColor,
),
// toggleableActiveColor: themeColor,
appBarTheme: AppBarTheme(centerTitle: centerTitle, backgroundColor: appBarColor),
);
}