From 91aec429b30e4fc4bea84eddd4d0851e4a18d31b Mon Sep 17 00:00:00 2001 From: Henri Sauer Date: Fri, 17 May 2024 15:45:55 +0200 Subject: [PATCH 1/3] dropdow menu item ink animations now hide behind the search widget, and don't get displayed above it. --- .../lib/src/dropdown_menu.dart | 132 +++++++++--------- 1 file changed, 67 insertions(+), 65 deletions(-) diff --git a/packages/dropdown_button2/lib/src/dropdown_menu.dart b/packages/dropdown_button2/lib/src/dropdown_menu.dart index a5a1bc5..a98efdf 100644 --- a/packages/dropdown_button2/lib/src/dropdown_menu.dart +++ b/packages/dropdown_button2/lib/src/dropdown_menu.dart @@ -158,72 +158,74 @@ 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, + child: Material( + 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, + ), ), - ), + ), ), ), ), From e74c7c6340ce9a9188abd76d756f04e4f686bce8 Mon Sep 17 00:00:00 2001 From: Ahmed Elsayed Date: Sun, 9 Jun 2024 00:28:19 +0300 Subject: [PATCH 2/3] Add font style to the material wrapper above menu's ListView --- packages/dropdown_button2/lib/src/dropdown_menu.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/dropdown_button2/lib/src/dropdown_menu.dart b/packages/dropdown_button2/lib/src/dropdown_menu.dart index a98efdf..9d8e18c 100644 --- a/packages/dropdown_button2/lib/src/dropdown_menu.dart +++ b/packages/dropdown_button2/lib/src/dropdown_menu.dart @@ -159,6 +159,8 @@ class _DropdownMenuState extends State<_DropdownMenu> { else Flexible( child: Material( + type: MaterialType.transparency, + textStyle: route.style, child: Padding( padding: dropdownStyle.scrollPadding ?? EdgeInsets.zero, child: ScrollConfiguration( From 955a27295c214aa69cd68f47d0fa1d798b88c8e6 Mon Sep 17 00:00:00 2001 From: Ahmed Elsayed Date: Sun, 9 Jun 2024 00:30:39 +0300 Subject: [PATCH 3/3] Update Changelog --- packages/dropdown_button2/CHANGELOG.md | 1 + packages/dropdown_button2/lib/src/dropdown_menu.dart | 3 +++ 2 files changed, 4 insertions(+) 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 9d8e18c..3f190da 100644 --- a/packages/dropdown_button2/lib/src/dropdown_menu.dart +++ b/packages/dropdown_button2/lib/src/dropdown_menu.dart @@ -158,6 +158,9 @@ class _DropdownMenuState extends State<_DropdownMenu> { searchData!.noResultsWidget! else Flexible( + // 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,