11part of 'dropdown_button2.dart' ;
22
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 ());
65
76class _MenuLimits {
87 const _MenuLimits (this .top, this .bottom, this .height, this .scrollOffset);
@@ -49,8 +48,7 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
4948
5049 DropdownSearchData <T >? get searchData => widget.route.searchData;
5150
52- _DropdownItemButton <T > dropdownItemButton (int index) =>
53- _DropdownItemButton <T >(
51+ _DropdownItemButton <T > dropdownItemButton (int index) => _DropdownItemButton <T >(
5452 route: widget.route,
5553 scrollController: widget.scrollController,
5654 textDirection: widget.textDirection,
@@ -83,8 +81,7 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
8381 final searchController = searchData? .searchController;
8482 if (searchController == null ) {
8583 _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),
8885 ];
8986 } else {
9087 _searchMatchFn = searchData? .searchMatchFn ?? _defaultSearchMatchFn ();
@@ -103,8 +100,7 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
103100 final String currentSearch = searchData! .searchController! .text;
104101 return < Widget > [
105102 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),
108104 ];
109105 }
110106
@@ -125,13 +121,11 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
125121
126122 ScrollbarThemeData ? get _scrollbarTheme => dropdownStyle.scrollbarTheme;
127123
128- bool get _iOSThumbVisibility =>
129- _scrollbarTheme? .thumbVisibility? .resolve (_states) ?? true ;
124+ bool get _iOSThumbVisibility => _scrollbarTheme? .thumbVisibility? .resolve (_states) ?? true ;
130125
131126 bool get _hasIntrinsicHeight =>
132127 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);
135129
136130 @override
137131 Widget build (BuildContext context) {
@@ -144,8 +138,7 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
144138 // When the menu is dismissed we just fade the entire thing out
145139 // in the first 0.25s.
146140 assert (debugCheckHasMaterialLocalizations (context));
147- final MaterialLocalizations localizations =
148- MaterialLocalizations .of (context);
141+ final MaterialLocalizations localizations = MaterialLocalizations .of (context);
149142 final _DropdownRoute <T > route = widget.route;
150143
151144 final separator = widget.route.dropdownSeparator;
@@ -189,24 +182,20 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
189182 thumbVisibility:
190183 // ignore: avoid_bool_literals_in_conditional_expressions
191184 _isIOS ? _iOSThumbVisibility : true ,
192- thickness: _isIOS
193- ? _scrollbarTheme? .thickness? .resolve (_states)
194- : null ,
185+ thickness: _isIOS ? _scrollbarTheme? .thickness? .resolve (_states) : null ,
195186 radius: _isIOS ? _scrollbarTheme? .radius : null ,
196187 child: ListView .custom (
197188 // Ensure this always inherits the PrimaryScrollController
198189 primary: true ,
199190 shrinkWrap: true ,
200- padding:
201- dropdownStyle.padding ?? kMaterialListPadding,
191+ padding: dropdownStyle.padding ?? kMaterialListPadding,
202192 itemExtentBuilder: _hasIntrinsicHeight
203193 ? null
204194 : (index, dimensions) {
205195 final childrenLength = separator == null
206196 ? _children.length
207197 : SeparatedSliverChildBuilderDelegate
208- .computeActualChildCount (
209- _children.length);
198+ .computeActualChildCount (_children.length);
210199 // TODO(Ahmed): Remove this when https://github.com/flutter/flutter/pull/142428
211200 // is supported by the min version of the package [Flutter>=3.22.0].
212201 if (index >= childrenLength) {
@@ -225,13 +214,9 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
225214 )
226215 : SeparatedSliverChildBuilderDelegate (
227216 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,
235220 child: separator,
236221 ),
237222 ),
@@ -265,13 +250,10 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
265250 label: localizations.popupMenuLabel,
266251 child: ClipRRect (
267252 //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,
275257 ),
276258 ),
277259 ),
@@ -290,8 +272,7 @@ class _DropdownMenuPainter extends CustomPainter {
290272 }) : _painter = dropdownDecoration
291273 ? .copyWith (
292274 color: dropdownDecoration.color ?? color,
293- boxShadow: dropdownDecoration.boxShadow ??
294- kElevationToShadow[elevation],
275+ boxShadow: dropdownDecoration.boxShadow ?? kElevationToShadow[elevation],
295276 )
296277 .createBoxPainter (() {}) ??
297278 BoxDecoration (
@@ -323,13 +304,11 @@ class _DropdownMenuPainter extends CustomPainter {
323304 );
324305
325306 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),
328308 end: size.height,
329309 );
330310
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));
333312
334313 _painter.paint (canvas, rect.topLeft, ImageConfiguration (size: rect.size));
335314 }
0 commit comments