mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
fix: ThemeMode not works under copied data
This commit is contained in:
30
lib/app.dart
30
lib/app.dart
@@ -41,6 +41,8 @@ class MyApp extends StatelessWidget {
|
||||
final radioTheme = RadioThemeData(
|
||||
fillColor: materialColor,
|
||||
);
|
||||
final primarySwatch = primaryColor.materialColor;
|
||||
|
||||
return ValueListenableBuilder<int>(
|
||||
valueListenable: _setting.themeMode.listenable(),
|
||||
builder: (_, tMode, __) {
|
||||
@@ -51,7 +53,7 @@ class MyApp extends StatelessWidget {
|
||||
useMaterial3: false,
|
||||
fontFamily: fontName,
|
||||
primaryColor: primaryColor,
|
||||
primarySwatch: primaryColor.materialColor,
|
||||
primarySwatch: primarySwatch,
|
||||
appBarTheme: appBarTheme,
|
||||
floatingActionButtonTheme: fabTheme,
|
||||
iconTheme: iconTheme,
|
||||
@@ -60,6 +62,24 @@ class MyApp extends StatelessWidget {
|
||||
inputDecorationTheme: inputDecorationTheme,
|
||||
radioTheme: radioTheme,
|
||||
);
|
||||
final darkTheme = ThemeData(
|
||||
useMaterial3: false,
|
||||
fontFamily: fontName,
|
||||
primaryColor: primaryColor,
|
||||
primarySwatch: primarySwatch,
|
||||
floatingActionButtonTheme: fabTheme,
|
||||
iconTheme: iconTheme,
|
||||
primaryIconTheme: iconTheme,
|
||||
switchTheme: switchTheme,
|
||||
inputDecorationTheme: inputDecorationTheme,
|
||||
radioTheme: radioTheme,
|
||||
brightness: Brightness.dark,
|
||||
colorScheme: ColorScheme.fromSwatch(
|
||||
primarySwatch: primaryColor.materialColor,
|
||||
brightness: Brightness.dark,
|
||||
accentColor: primaryColor,
|
||||
),
|
||||
);
|
||||
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
@@ -68,13 +88,7 @@ class MyApp extends StatelessWidget {
|
||||
title: BuildData.name,
|
||||
themeMode: themeMode,
|
||||
theme: theme,
|
||||
darkTheme: theme.copyWith(
|
||||
colorScheme: ColorScheme.fromSwatch(
|
||||
primarySwatch: primaryColor.materialColor,
|
||||
brightness: Brightness.dark,
|
||||
accentColor: primaryColor,
|
||||
),
|
||||
),
|
||||
darkTheme: darkTheme,
|
||||
home: const MyHomePage(),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user