Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Ink splashes got displayed over search widget #291

Merged
merged 3 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/dropdown_button2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
137 changes: 72 additions & 65 deletions packages/dropdown_button2/lib/src/dropdown_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,72 +158,79 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
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,
),
),
),
),
),
),
),
Expand Down
Loading