getTheme function
Implementation
ThemeData getTheme({bool darkMode = false, required bool useMaterial3}) {
return ThemeData(
useMaterial3: useMaterial3,
platform: setTargetPlatform,
splashColor: Colors.transparent,
colorScheme: ColorScheme.fromSwatch().copyWith(
brightness: darkMode ? Brightness.dark : Brightness.light,
primary:
darkMode ? setDarkPrimarySwatchColor : setLightPrimarySwatchColor,
surfaceTint: Colors.transparent,
),
primaryColor: darkMode ? setDarkPrimaryColor : setLightPrimaryColor,
// 页面背景色
scaffoldBackgroundColor: darkMode
? setDarkScaffoldBackgroundColor
: setLightScaffoldBackgroundColor,
// Tab指示器颜色
indicatorColor: darkMode ? setDarkPrimaryColor : setLightPrimaryColor,
dividerColor: darkMode ? setDarkDividerColor : setLightDividerColor,
appBarTheme: AppBarTheme(
elevation: 0.0,
foregroundColor: darkMode
? setDarkAppBarForegroundColor
: setLightAppBarForegroundColor,
color: darkMode
? setDarkAppBarBackgroundColor
: setLightAppBarBackgroundColor,
systemOverlayStyle: darkMode
? setDarkAppBarSystemOverlayStyle
: setLightAppBarSystemOverlayStyle,
titleTextStyle:
darkMode ? setDarkAppBarTitleTextStyle : setLightAppBarTitleTextStyle,
centerTitle: setAppBarCenterTitle,
),
fontFamily: setThemeDataFontFamily,
textTheme: TextTheme(
// 默认 Text 样式
bodyMedium: darkMode ? setDarkBodyMediumStyle : setLightBodyMediumStyle,
),
);
}