Skip to content

Commit 9b4942b

Browse files
authored
Merge pull request #82 from garv-shah/master
Fixes Material Picker: Box shadow doesn't respect theme
2 parents 41b912f + 0ebd247 commit 9b4942b

File tree

5 files changed

+89
-89
lines changed

5 files changed

+89
-89
lines changed

example/pubspec.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ packages:
1414
name: collection
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "1.15.0"
17+
version: "1.16.0"
1818
flutter:
1919
dependency: "direct main"
2020
description: flutter
@@ -41,6 +41,13 @@ packages:
4141
url: "https://pub.dartlang.org"
4242
source: hosted
4343
version: "1.0.1"
44+
material_color_utilities:
45+
dependency: transitive
46+
description:
47+
name: material_color_utilities
48+
url: "https://pub.dartlang.org"
49+
source: hosted
50+
version: "0.1.4"
4451
meta:
4552
dependency: transitive
4653
description:
@@ -53,20 +60,13 @@ packages:
5360
description: flutter
5461
source: sdk
5562
version: "0.0.99"
56-
typed_data:
57-
dependency: transitive
58-
description:
59-
name: typed_data
60-
url: "https://pub.dartlang.org"
61-
source: hosted
62-
version: "1.3.0"
6363
vector_math:
6464
dependency: transitive
6565
description:
6666
name: vector_math
6767
url: "https://pub.dartlang.org"
6868
source: hosted
69-
version: "2.1.1"
69+
version: "2.1.2"
7070
sdks:
7171
dart: ">=2.14.0 <3.0.0"
72-
flutter: ">=1.17.0"
72+
flutter: ">=2.0.0"
-1.81 KB
Loading
-9.97 KB
Loading

lib/src/material_picker.dart

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ class _MaterialPickerState extends State<MaterialPicker> {
110110
height: _isPortrait ? null : 60,
111111
decoration: BoxDecoration(
112112
color: Theme.of(context).cardColor,
113-
boxShadow: [BoxShadow(color: Colors.grey[300]!, blurRadius: 10)],
113+
boxShadow: [BoxShadow(color: (Theme.of(context).brightness == Brightness.light) ? (Theme.of(context).brightness == Brightness.light) ? Colors.grey[300]! : Colors.black38 : Colors.black38, blurRadius: 10)],
114114
border: _isPortrait
115-
? Border(right: BorderSide(color: Colors.grey[300]!, width: 1))
116-
: Border(top: BorderSide(color: Colors.grey[300]!, width: 1)),
115+
? Border(right: BorderSide(color: (Theme.of(context).brightness == Brightness.light) ? Colors.grey[300]! : Colors.black38, width: 1))
116+
: Border(top: BorderSide(color: (Theme.of(context).brightness == Brightness.light) ? Colors.grey[300]! : Colors.black38, width: 1)),
117117
),
118118
child: ScrollConfiguration(
119119
behavior: ScrollConfiguration.of(context).copyWith(dragDevices: PointerDeviceKind.values.toSet()),
@@ -133,7 +133,7 @@ class _MaterialPickerState extends State<MaterialPicker> {
133133
child: Container(
134134
color: const Color(0x00000000),
135135
padding:
136-
_isPortrait ? const EdgeInsets.fromLTRB(0, 7, 0, 7) : const EdgeInsets.fromLTRB(7, 0, 7, 0),
136+
_isPortrait ? const EdgeInsets.fromLTRB(0, 7, 0, 7) : const EdgeInsets.fromLTRB(7, 0, 7, 0),
137137
child: Align(
138138
child: AnimatedContainer(
139139
duration: const Duration(milliseconds: 300),
@@ -144,19 +144,19 @@ class _MaterialPickerState extends State<MaterialPicker> {
144144
shape: BoxShape.circle,
145145
boxShadow: _currentColorType == _colors
146146
? [
147-
_colorType == Theme.of(context).cardColor
148-
? BoxShadow(
149-
color: Colors.grey[300]!,
150-
blurRadius: 10,
151-
)
152-
: BoxShadow(
153-
color: _colorType,
154-
blurRadius: 10,
155-
),
156-
]
147+
_colorType == Theme.of(context).cardColor
148+
? BoxShadow(
149+
color: (Theme.of(context).brightness == Brightness.light) ? Colors.grey[300]! : Colors.black38,
150+
blurRadius: 10,
151+
)
152+
: BoxShadow(
153+
color: _colorType,
154+
blurRadius: 10,
155+
),
156+
]
157157
: null,
158158
border: _colorType == Theme.of(context).cardColor
159-
? Border.all(color: Colors.grey[300]!, width: 1)
159+
? Border.all(color: (Theme.of(context).brightness == Brightness.light) ? Colors.grey[300]! : Colors.black38, width: 1)
160160
: null,
161161
),
162162
),
@@ -199,66 +199,66 @@ class _MaterialPickerState extends State<MaterialPicker> {
199199
curve: Curves.fastOutSlowIn,
200200
duration: const Duration(milliseconds: 500),
201201
width:
202-
_isPortrait ? (_currentShading == _color ? 250 : 230) : (_currentShading == _color ? 50 : 30),
202+
_isPortrait ? (_currentShading == _color ? 250 : 230) : (_currentShading == _color ? 50 : 30),
203203
height: _isPortrait ? 50 : 220,
204204
decoration: BoxDecoration(
205205
color: _color,
206206
boxShadow: _currentShading == _color
207207
? [
208-
(_color == Colors.white) || (_color == Colors.black)
209-
? BoxShadow(
210-
color: Colors.grey[300]!,
211-
blurRadius: 10,
212-
)
213-
: BoxShadow(
214-
color: _color,
215-
blurRadius: 10,
216-
),
217-
]
208+
(_color == Colors.white) || (_color == Colors.black)
209+
? BoxShadow(
210+
color: (Theme.of(context).brightness == Brightness.light) ? Colors.grey[300]! : Colors.black38,
211+
blurRadius: 10,
212+
)
213+
: BoxShadow(
214+
color: _color,
215+
blurRadius: 10,
216+
),
217+
]
218218
: null,
219219
border: (_color == Colors.white) || (_color == Colors.black)
220-
? Border.all(color: Colors.grey[300]!, width: 1)
220+
? Border.all(color: (Theme.of(context).brightness == Brightness.light) ? Colors.grey[300]! : Colors.black38, width: 1)
221221
: null,
222222
),
223223
child: widget.enableLabel
224224
? _isPortrait
225-
? Row(
226-
children: [
227-
Text(
228-
' ${color.values.first}',
229-
style: TextStyle(color: useWhiteForeground(_color) ? Colors.white : Colors.black),
230-
),
231-
Expanded(
232-
child: Align(
233-
alignment: Alignment.centerRight,
234-
child: Text(
235-
'#${(_color.toString().replaceFirst('Color(0xff', '').replaceFirst(')', '')).toUpperCase()} ',
236-
style: TextStyle(
237-
color: useWhiteForeground(_color) ? Colors.white : Colors.black,
238-
fontWeight: FontWeight.bold,
239-
),
240-
),
241-
),
242-
),
243-
],
244-
)
245-
: AnimatedOpacity(
246-
duration: const Duration(milliseconds: 300),
247-
opacity: _currentShading == _color ? 1 : 0,
248-
child: Container(
249-
padding: const EdgeInsets.only(top: 16),
250-
alignment: Alignment.topCenter,
251-
child: Text(
252-
color.values.first,
253-
style: TextStyle(
254-
color: useWhiteForeground(_color) ? Colors.white : Colors.black,
255-
fontWeight: FontWeight.bold,
256-
fontSize: 14,
257-
),
258-
softWrap: false,
259-
),
260-
),
261-
)
225+
? Row(
226+
children: [
227+
Text(
228+
' ${color.values.first}',
229+
style: TextStyle(color: useWhiteForeground(_color) ? Colors.white : Colors.black),
230+
),
231+
Expanded(
232+
child: Align(
233+
alignment: Alignment.centerRight,
234+
child: Text(
235+
'#${(_color.toString().replaceFirst('Color(0xff', '').replaceFirst(')', '')).toUpperCase()} ',
236+
style: TextStyle(
237+
color: useWhiteForeground(_color) ? Colors.white : Colors.black,
238+
fontWeight: FontWeight.bold,
239+
),
240+
),
241+
),
242+
),
243+
],
244+
)
245+
: AnimatedOpacity(
246+
duration: const Duration(milliseconds: 300),
247+
opacity: _currentShading == _color ? 1 : 0,
248+
child: Container(
249+
padding: const EdgeInsets.only(top: 16),
250+
alignment: Alignment.topCenter,
251+
child: Text(
252+
color.values.first,
253+
style: TextStyle(
254+
color: useWhiteForeground(_color) ? Colors.white : Colors.black,
255+
fontWeight: FontWeight.bold,
256+
fontSize: 14,
257+
),
258+
softWrap: false,
259+
),
260+
),
261+
)
262262
: const SizedBox(),
263263
),
264264
),

pubspec.lock

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ packages:
4242
name: collection
4343
url: "https://pub.dartlang.org"
4444
source: hosted
45-
version: "1.15.0"
45+
version: "1.16.0"
4646
fake_async:
4747
dependency: transitive
4848
description:
4949
name: fake_async
5050
url: "https://pub.dartlang.org"
5151
source: hosted
52-
version: "1.2.0"
52+
version: "1.3.0"
5353
flutter:
5454
dependency: "direct main"
5555
description: flutter
@@ -81,6 +81,13 @@ packages:
8181
url: "https://pub.dartlang.org"
8282
source: hosted
8383
version: "0.12.11"
84+
material_color_utilities:
85+
dependency: transitive
86+
description:
87+
name: material_color_utilities
88+
url: "https://pub.dartlang.org"
89+
source: hosted
90+
version: "0.1.4"
8491
meta:
8592
dependency: transitive
8693
description:
@@ -94,7 +101,7 @@ packages:
94101
name: path
95102
url: "https://pub.dartlang.org"
96103
source: hosted
97-
version: "1.8.0"
104+
version: "1.8.1"
98105
sky_engine:
99106
dependency: transitive
100107
description: flutter
@@ -106,7 +113,7 @@ packages:
106113
name: source_span
107114
url: "https://pub.dartlang.org"
108115
source: hosted
109-
version: "1.8.1"
116+
version: "1.8.2"
110117
stack_trace:
111118
dependency: transitive
112119
description:
@@ -141,21 +148,14 @@ packages:
141148
name: test_api
142149
url: "https://pub.dartlang.org"
143150
source: hosted
144-
version: "0.4.3"
145-
typed_data:
146-
dependency: transitive
147-
description:
148-
name: typed_data
149-
url: "https://pub.dartlang.org"
150-
source: hosted
151-
version: "1.3.0"
151+
version: "0.4.9"
152152
vector_math:
153153
dependency: transitive
154154
description:
155155
name: vector_math
156156
url: "https://pub.dartlang.org"
157157
source: hosted
158-
version: "2.1.1"
158+
version: "2.1.2"
159159
sdks:
160-
dart: ">=2.14.0 <3.0.0"
161-
flutter: ">=1.17.0"
160+
dart: ">=2.17.0-0 <3.0.0"
161+
flutter: ">=2.0.0"

0 commit comments

Comments
 (0)