Skip to content

Commit 9fa042c

Browse files
committed
update README.MD
1 parent 26db4c7 commit 9fa042c

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

README.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ GetxApp 是 GetMaterialApp 嵌套了 ScreenUtilInit 对全局进行屏幕适配
127127

128128
#### 3. 定义主题
129129

130+
最近新项目的使用中,发现这 Material3 实在没法用,各种配色问题莫名其妙。从 0.2.0 开始推荐使用 Material2 重新适配,具体主题设置参考 Example。
131+
130132
```dart
131133
import 'package:flutter/material.dart';
132134
@@ -135,37 +137,49 @@ class AppTheme {
135137
136138
static const Color themeColor = Color.fromARGB(255, 11, 107, 47);
137139
138-
static const Color darkThemeColor = Color.fromARGB(255, 27, 31, 139);
140+
static const Color darkThemeColor = Color.fromARGB(255, 12, 16, 121);
139141
140142
/// 亮色主题样式
141143
static ThemeData light = ThemeData(
144+
useMaterial3: false,
145+
fontFamily: fontMontserrat,
142146
colorScheme: ColorScheme.fromSeed(
143147
seedColor: themeColor,
144148
brightness: Brightness.light,
145149
),
146-
fontFamily: fontMontserrat,
147-
cardTheme: CardTheme(
148-
surfaceTintColor: Colors.white,
149-
shape: RoundedRectangleBorder(
150-
borderRadius: BorderRadius.circular(6),
150+
appBarTheme: const AppBarTheme(
151+
backgroundColor: Colors.white,
152+
foregroundColor: Color.fromARGB(200, 0, 0, 0),
153+
centerTitle: true,
154+
titleTextStyle: TextStyle(
155+
fontSize: 18,
156+
fontWeight: FontWeight.bold,
157+
color: Color.fromARGB(200, 0, 0, 0),
151158
),
152159
),
153160
);
154161
155162
/// 暗色主题样式
156163
static ThemeData dark = ThemeData(
164+
useMaterial3: false,
165+
fontFamily: fontMontserrat,
157166
colorScheme: ColorScheme.fromSeed(
158167
seedColor: darkThemeColor,
159168
brightness: Brightness.dark,
160169
),
161-
fontFamily: fontMontserrat,
162-
cardTheme: CardTheme(
163-
shape: RoundedRectangleBorder(
164-
borderRadius: BorderRadius.circular(6),
170+
appBarTheme: const AppBarTheme(
171+
centerTitle: true,
172+
titleTextStyle: TextStyle(
173+
fontSize: 18,
174+
fontWeight: FontWeight.bold,
165175
),
166176
),
177+
bottomAppBarTheme: const BottomAppBarTheme(
178+
color: Color.fromARGB(255, 34, 34, 34),
179+
),
167180
);
168181
}
182+
169183
```
170184

171185
以上是主题示例,GetXScaffold 的所有内置组件均遵循 Material3 设计规范。如果你使用 colorScheme 定义了主题颜色,那么你可以通过以下方法使用所有的主题颜色:

0 commit comments

Comments
 (0)