@@ -678,9 +678,6 @@ class _SearchFieldState<T> extends State<SearchField<T>> {
678
678
@override
679
679
void didChangeDependencies () {
680
680
// update overlay dimensions on mediaQuery change
681
- if (mounted) {
682
- _calculateDimensions ();
683
- }
684
681
if (_overlayEntry != null && _overlayEntry! .mounted) {
685
682
WidgetsBinding .instance.addPostFrameCallback ((timeStamp) {
686
683
if (mounted) {
@@ -925,36 +922,45 @@ class _SearchFieldState<T> extends State<SearchField<T>> {
925
922
// final textFieldsize = textFieldRenderBox.size;
926
923
// final offset = textFieldRenderBox.localToGlobal(Offset.zero);
927
924
// var yOffset = Offset.zero;
928
- return StreamBuilder <List <SearchFieldListItem ?>?>(
929
- stream: suggestionStream.stream,
930
- builder: (BuildContext context,
931
- AsyncSnapshot <List <SearchFieldListItem ?>?> snapshot) {
932
- late var count = widget.maxSuggestionsInViewPort;
933
- if (snapshot.data != null ) {
934
- count = snapshot.data! .length;
935
- }
936
- var yOffset = Offset .zero;
937
- if (widget.offset == null ) {
938
- yOffset = getYOffset (count) ?? Offset .zero;
939
- }
940
- return Positioned (
941
- left: searchFieldDimensions.offset! .dx,
942
- width: widget.suggestionsDecoration? .width ??
943
- searchFieldDimensions.width,
944
- child: CompositedTransformFollower (
945
- offset: widget.offset ?? yOffset,
946
- link: _layerLink,
947
- child: Material (
948
- borderRadius: widget.suggestionsDecoration? .borderRadius ??
949
- BorderRadius .zero,
950
- shadowColor: widget.suggestionsDecoration? .shadowColor,
951
- elevation: widget.suggestionsDecoration? .elevation ??
952
- kDefaultElevation,
953
- child: _suggestionsBuilder (),
954
- ),
955
- ),
956
- );
957
- });
925
+ return LayoutBuilder (
926
+ builder: (BuildContext context, BoxConstraints constraints) {
927
+ _calculateDimensions ();
928
+ return StreamBuilder <List <SearchFieldListItem ?>?>(
929
+ stream: suggestionStream.stream,
930
+ builder: (BuildContext context,
931
+ AsyncSnapshot <List <SearchFieldListItem ?>?> snapshot) {
932
+ late var count = widget.maxSuggestionsInViewPort;
933
+ if (snapshot.data != null ) {
934
+ count = snapshot.data! .length;
935
+ }
936
+ var yOffset = Offset .zero;
937
+ if (widget.offset == null ) {
938
+ yOffset = getYOffset (count) ?? Offset .zero;
939
+ }
940
+ return Stack (
941
+ children: [
942
+ Positioned (
943
+ left: searchFieldDimensions.offset! .dx,
944
+ width: widget.suggestionsDecoration? .width ??
945
+ searchFieldDimensions.width,
946
+ child: CompositedTransformFollower (
947
+ offset: widget.offset ?? yOffset,
948
+ link: _layerLink,
949
+ child: Material (
950
+ borderRadius:
951
+ widget.suggestionsDecoration? .borderRadius ??
952
+ BorderRadius .zero,
953
+ shadowColor: widget.suggestionsDecoration? .shadowColor,
954
+ elevation: widget.suggestionsDecoration? .elevation ??
955
+ kDefaultElevation,
956
+ child: _suggestionsBuilder (),
957
+ ),
958
+ ),
959
+ ),
960
+ ],
961
+ );
962
+ });
963
+ });
958
964
});
959
965
}
960
966
0 commit comments