diff --git a/packages/dropdown_button2/CHANGELOG.md b/packages/dropdown_button2/CHANGELOG.md index e3c1d9b..9c7b707 100644 --- a/packages/dropdown_button2/CHANGELOG.md +++ b/packages/dropdown_button2/CHANGELOG.md @@ -1,6 +1,7 @@ ## UNRELEASED - Enhance scroll position when using searchable dropdown, closes #285. +- Temporarily fix ink splash gets displayed over search widget, closes #290. ## 3.0.0-beta.16 diff --git a/packages/dropdown_button2/lib/src/dropdown_menu.dart b/packages/dropdown_button2/lib/src/dropdown_menu.dart index a5a1bc5..3f190da 100644 --- a/packages/dropdown_button2/lib/src/dropdown_menu.dart +++ b/packages/dropdown_button2/lib/src/dropdown_menu.dart @@ -158,72 +158,79 @@ class _DropdownMenuState extends State<_DropdownMenu> { searchData!.noResultsWidget! else Flexible( - child: Padding( - padding: dropdownStyle.scrollPadding ?? EdgeInsets.zero, - child: ScrollConfiguration( - // Dropdown menus should never overscroll or display an overscroll indicator. - // Scrollbars are built-in below. - // Platform must use Theme and ScrollPhysics must be Clamping. - behavior: ScrollConfiguration.of(context).copyWith( - scrollbars: false, - overscroll: false, - physics: const ClampingScrollPhysics(), - platform: Theme.of(context).platform, - ), - child: PrimaryScrollController( - controller: route.scrollController!, - child: Theme( - data: Theme.of(context).copyWith( - scrollbarTheme: dropdownStyle.scrollbarTheme, - ), - child: Scrollbar( - thumbVisibility: - // ignore: avoid_bool_literals_in_conditional_expressions - _isIOS ? _iOSThumbVisibility : true, - thickness: _isIOS - ? _scrollbarTheme?.thickness?.resolve(_states) - : null, - radius: _isIOS ? _scrollbarTheme?.radius : null, - child: ListView.custom( - // Ensure this always inherits the PrimaryScrollController - primary: true, - shrinkWrap: true, - padding: - dropdownStyle.padding ?? kMaterialListPadding, - itemExtentBuilder: _hasIntrinsicHeight - ? null - : (index, dimensions) { - final childrenLength = separator == null - ? _children.length - : SeparatedSliverChildBuilderDelegate - .computeActualChildCount( - _children.length); - // TODO(Ahmed): Remove this when https://github.com/flutter/flutter/pull/142428 - // is supported by the min version of the package [Flutter>=3.22.0]. - if (index >= childrenLength) { - return 100; - } - return separator != null && index.isOdd - ? separator.height - : route.itemHeights[index]; - }, - childrenDelegate: separator == null - ? SliverChildBuilderDelegate( - (context, index) => _children[index], - childCount: _children.length, - ) - : SeparatedSliverChildBuilderDelegate( - itemCount: _children.length, - itemBuilder: (context, index) => - _children[index], - separatorBuilder: (context, index) => - SizedBox( - height: separator.intrinsicHeight - ? null - : separator.height, - child: separator, + // This Material wrapper is temporary until it's fixed by flutter at: + // https://github.com/flutter/flutter/issues/86584 + // https://github.com/flutter/flutter/issues/73315 + child: Material( + type: MaterialType.transparency, + textStyle: route.style, + child: Padding( + padding: dropdownStyle.scrollPadding ?? EdgeInsets.zero, + child: ScrollConfiguration( + // Dropdown menus should never overscroll or display an overscroll indicator. + // Scrollbars are built-in below. + // Platform must use Theme and ScrollPhysics must be Clamping. + behavior: ScrollConfiguration.of(context).copyWith( + scrollbars: false, + overscroll: false, + physics: const ClampingScrollPhysics(), + platform: Theme.of(context).platform, + ), + child: PrimaryScrollController( + controller: route.scrollController!, + child: Theme( + data: Theme.of(context).copyWith( + scrollbarTheme: dropdownStyle.scrollbarTheme, + ), + child: Scrollbar( + thumbVisibility: + // ignore: avoid_bool_literals_in_conditional_expressions + _isIOS ? _iOSThumbVisibility : true, + thickness: _isIOS + ? _scrollbarTheme?.thickness?.resolve(_states) + : null, + radius: _isIOS ? _scrollbarTheme?.radius : null, + child: ListView.custom( + // Ensure this always inherits the PrimaryScrollController + primary: true, + shrinkWrap: true, + padding: + dropdownStyle.padding ?? kMaterialListPadding, + itemExtentBuilder: _hasIntrinsicHeight + ? null + : (index, dimensions) { + final childrenLength = separator == null + ? _children.length + : SeparatedSliverChildBuilderDelegate + .computeActualChildCount( + _children.length); + // TODO(Ahmed): Remove this when https://github.com/flutter/flutter/pull/142428 + // is supported by the min version of the package [Flutter>=3.22.0]. + if (index >= childrenLength) { + return 100; + } + return separator != null && index.isOdd + ? separator.height + : route.itemHeights[index]; + }, + childrenDelegate: separator == null + ? SliverChildBuilderDelegate( + (context, index) => _children[index], + childCount: _children.length, + ) + : SeparatedSliverChildBuilderDelegate( + itemCount: _children.length, + itemBuilder: (context, index) => + _children[index], + separatorBuilder: (context, index) => + SizedBox( + height: separator.intrinsicHeight + ? null + : separator.height, + child: separator, + ), ), - ), + ), ), ), ),