@@ -127,6 +127,8 @@ GetxApp 是 GetMaterialApp 嵌套了 ScreenUtilInit 对全局进行屏幕适配
127
127
128
128
#### 3. 定义主题
129
129
130
+ 最近新项目的使用中,发现这 Material3 实在没法用,各种配色问题莫名其妙。从 0.2.0 开始推荐使用 Material2 重新适配,具体主题设置参考 Example。
131
+
130
132
``` dart
131
133
import 'package:flutter/material.dart';
132
134
@@ -135,37 +137,49 @@ class AppTheme {
135
137
136
138
static const Color themeColor = Color.fromARGB(255, 11, 107, 47);
137
139
138
- static const Color darkThemeColor = Color.fromARGB(255, 27, 31, 139 );
140
+ static const Color darkThemeColor = Color.fromARGB(255, 12, 16, 121 );
139
141
140
142
/// 亮色主题样式
141
143
static ThemeData light = ThemeData(
144
+ useMaterial3: false,
145
+ fontFamily: fontMontserrat,
142
146
colorScheme: ColorScheme.fromSeed(
143
147
seedColor: themeColor,
144
148
brightness: Brightness.light,
145
149
),
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),
151
158
),
152
159
),
153
160
);
154
161
155
162
/// 暗色主题样式
156
163
static ThemeData dark = ThemeData(
164
+ useMaterial3: false,
165
+ fontFamily: fontMontserrat,
157
166
colorScheme: ColorScheme.fromSeed(
158
167
seedColor: darkThemeColor,
159
168
brightness: Brightness.dark,
160
169
),
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,
165
175
),
166
176
),
177
+ bottomAppBarTheme: const BottomAppBarTheme(
178
+ color: Color.fromARGB(255, 34, 34, 34),
179
+ ),
167
180
);
168
181
}
182
+
169
183
```
170
184
171
185
以上是主题示例,GetXScaffold 的所有内置组件均遵循 Material3 设计规范。如果你使用 colorScheme 定义了主题颜色,那么你可以通过以下方法使用所有的主题颜色:
0 commit comments