Skip to content

Commit 0895ff2

Browse files
committed
♻️ Refactored theme definition for fully theme customization.
1 parent 77e5287 commit 0895ff2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/src/widget/asset_picker.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,18 @@ class AssetPicker extends StatelessWidget {
2525
AssetPicker({
2626
Key key,
2727
@required this.provider,
28+
this.pickerTheme,
2829
int gridCount = 4,
2930
Color themeColor = C.themeColor,
3031
TextDelegate textDelegate,
3132
}) : assert(
3233
provider != null,
3334
'AssetPickerProvider must be provided and not null.',
3435
),
36+
assert(
37+
pickerTheme == null || themeColor == null,
38+
'Theme and theme color cannot be set at the same time.',
39+
),
3540
gridCount = gridCount ?? 4,
3641
themeColor = themeColor ?? C.themeColor,
3742
super(key: key) {
@@ -50,6 +55,14 @@ class AssetPicker extends StatelessWidget {
5055
/// 选择器的主题色
5156
final Color themeColor;
5257

58+
/// Theme for the picker.
59+
/// 选择器的主题
60+
///
61+
/// Usually the WeChat uses the dark version (dark background color) for the picker,
62+
/// but some developer wants a light theme version for some reasons.
63+
/// 通常情况下微信选择器使用的是暗色(暗色背景)的主题,但某些情况下开发者需要亮色或自定义主题。
64+
final ThemeData pickerTheme;
65+
5366
/// Static method to push with navigator.
5467
/// 跳转至选择器的静态方法
5568
static Future<List<AssetEntity>> pickAssets(
@@ -161,7 +174,7 @@ class AssetPicker extends StatelessWidget {
161174
),
162175
);
163176

164-
ThemeData get theme => themeData(themeColor);
177+
ThemeData get theme => pickerTheme ?? themeData(themeColor);
165178

166179
/// Path entity select widget.
167180
/// 路径选择部件

0 commit comments

Comments
 (0)