1
1
part of 'dropdown_button2.dart' ;
2
2
3
- SearchMatchFn <T > _defaultSearchMatchFn <T >() =>
4
- (DropdownItem <T > item, String searchValue) =>
5
- item.value.toString ().toLowerCase ().contains (searchValue.toLowerCase ());
3
+ SearchMatchFn <T > _defaultSearchMatchFn <T >() => (DropdownItem <T > item, String searchValue) =>
4
+ item.value.toString ().toLowerCase ().contains (searchValue.toLowerCase ());
6
5
7
6
class _MenuLimits {
8
7
const _MenuLimits (this .top, this .bottom, this .height, this .scrollOffset);
@@ -49,8 +48,7 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
49
48
50
49
DropdownSearchData <T >? get searchData => widget.route.searchData;
51
50
52
- _DropdownItemButton <T > dropdownItemButton (int index) =>
53
- _DropdownItemButton <T >(
51
+ _DropdownItemButton <T > dropdownItemButton (int index) => _DropdownItemButton <T >(
54
52
route: widget.route,
55
53
scrollController: widget.scrollController,
56
54
textDirection: widget.textDirection,
@@ -83,8 +81,7 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
83
81
final searchController = searchData? .searchController;
84
82
if (searchController == null ) {
85
83
_children = < Widget > [
86
- for (int index = 0 ; index < items.length; ++ index)
87
- dropdownItemButton (index),
84
+ for (int index = 0 ; index < items.length; ++ index) dropdownItemButton (index),
88
85
];
89
86
} else {
90
87
_searchMatchFn = searchData? .searchMatchFn ?? _defaultSearchMatchFn ();
@@ -103,8 +100,7 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
103
100
final String currentSearch = searchData! .searchController! .text;
104
101
return < Widget > [
105
102
for (int index = 0 ; index < items.length; ++ index)
106
- if (_searchMatchFn (items[index], currentSearch))
107
- dropdownItemButton (index),
103
+ if (_searchMatchFn (items[index], currentSearch)) dropdownItemButton (index),
108
104
];
109
105
}
110
106
@@ -125,13 +121,11 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
125
121
126
122
ScrollbarThemeData ? get _scrollbarTheme => dropdownStyle.scrollbarTheme;
127
123
128
- bool get _iOSThumbVisibility =>
129
- _scrollbarTheme? .thumbVisibility? .resolve (_states) ?? true ;
124
+ bool get _iOSThumbVisibility => _scrollbarTheme? .thumbVisibility? .resolve (_states) ?? true ;
130
125
131
126
bool get _hasIntrinsicHeight =>
132
127
widget.route.items.any ((item) => item.intrinsicHeight) ||
133
- (widget.route.dropdownSeparator != null &&
134
- widget.route.dropdownSeparator! .intrinsicHeight);
128
+ (widget.route.dropdownSeparator != null && widget.route.dropdownSeparator! .intrinsicHeight);
135
129
136
130
@override
137
131
Widget build (BuildContext context) {
@@ -144,8 +138,7 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
144
138
// When the menu is dismissed we just fade the entire thing out
145
139
// in the first 0.25s.
146
140
assert (debugCheckHasMaterialLocalizations (context));
147
- final MaterialLocalizations localizations =
148
- MaterialLocalizations .of (context);
141
+ final MaterialLocalizations localizations = MaterialLocalizations .of (context);
149
142
final _DropdownRoute <T > route = widget.route;
150
143
151
144
final separator = widget.route.dropdownSeparator;
@@ -189,24 +182,20 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
189
182
thumbVisibility:
190
183
// ignore: avoid_bool_literals_in_conditional_expressions
191
184
_isIOS ? _iOSThumbVisibility : true ,
192
- thickness: _isIOS
193
- ? _scrollbarTheme? .thickness? .resolve (_states)
194
- : null ,
185
+ thickness: _isIOS ? _scrollbarTheme? .thickness? .resolve (_states) : null ,
195
186
radius: _isIOS ? _scrollbarTheme? .radius : null ,
196
187
child: ListView .custom (
197
188
// Ensure this always inherits the PrimaryScrollController
198
189
primary: true ,
199
190
shrinkWrap: true ,
200
- padding:
201
- dropdownStyle.padding ?? kMaterialListPadding,
191
+ padding: dropdownStyle.padding ?? kMaterialListPadding,
202
192
itemExtentBuilder: _hasIntrinsicHeight
203
193
? null
204
194
: (index, dimensions) {
205
195
final childrenLength = separator == null
206
196
? _children.length
207
197
: SeparatedSliverChildBuilderDelegate
208
- .computeActualChildCount (
209
- _children.length);
198
+ .computeActualChildCount (_children.length);
210
199
// TODO(Ahmed): Remove this when https://github.com/flutter/flutter/pull/142428
211
200
// is supported by the min version of the package [Flutter>=3.22.0].
212
201
if (index >= childrenLength) {
@@ -225,13 +214,9 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
225
214
)
226
215
: SeparatedSliverChildBuilderDelegate (
227
216
itemCount: _children.length,
228
- itemBuilder: (context, index) =>
229
- _children[index],
230
- separatorBuilder: (context, index) =>
231
- SizedBox (
232
- height: separator.intrinsicHeight
233
- ? null
234
- : separator.height,
217
+ itemBuilder: (context, index) => _children[index],
218
+ separatorBuilder: (context, index) => SizedBox (
219
+ height: separator.intrinsicHeight ? null : separator.height,
235
220
child: separator,
236
221
),
237
222
),
@@ -265,13 +250,10 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
265
250
label: localizations.popupMenuLabel,
266
251
child: ClipRRect (
267
252
//Prevent scrollbar, ripple effect & items from going beyond border boundaries when scrolling.
268
- clipBehavior: dropdownStyle.decoration? .borderRadius != null
269
- ? Clip .antiAlias
270
- : Clip .none,
271
- borderRadius:
272
- dropdownStyle.decoration? .borderRadius ?? BorderRadius .zero,
273
- child: dropdownStyle.dropdownBuilder? .call (context, dropdownMenu) ??
274
- dropdownMenu,
253
+ clipBehavior:
254
+ dropdownStyle.decoration? .borderRadius != null ? Clip .antiAlias : Clip .none,
255
+ borderRadius: dropdownStyle.decoration? .borderRadius ?? BorderRadius .zero,
256
+ child: dropdownStyle.dropdownBuilder? .call (context, dropdownMenu) ?? dropdownMenu,
275
257
),
276
258
),
277
259
),
@@ -290,8 +272,7 @@ class _DropdownMenuPainter extends CustomPainter {
290
272
}) : _painter = dropdownDecoration
291
273
? .copyWith (
292
274
color: dropdownDecoration.color ?? color,
293
- boxShadow: dropdownDecoration.boxShadow ??
294
- kElevationToShadow[elevation],
275
+ boxShadow: dropdownDecoration.boxShadow ?? kElevationToShadow[elevation],
295
276
)
296
277
.createBoxPainter (() {}) ??
297
278
BoxDecoration (
@@ -323,13 +304,11 @@ class _DropdownMenuPainter extends CustomPainter {
323
304
);
324
305
325
306
final Tween <double > bottom = Tween <double >(
326
- begin: clampDouble (top.begin! + itemHeight,
327
- math.min (itemHeight, size.height), size.height),
307
+ begin: clampDouble (top.begin! + itemHeight, math.min (itemHeight, size.height), size.height),
328
308
end: size.height,
329
309
);
330
310
331
- final Rect rect = Rect .fromLTRB (
332
- 0.0 , top.evaluate (resize), size.width, bottom.evaluate (resize));
311
+ final Rect rect = Rect .fromLTRB (0.0 , top.evaluate (resize), size.width, bottom.evaluate (resize));
333
312
334
313
_painter.paint (canvas, rect.topLeft, ImageConfiguration (size: rect.size));
335
314
}
0 commit comments