Closed bebaoboy closed 4 months ago
Thanks for catching that, we definetly need to fix that logic and have basic sanity checks such as zero or negative height.
Anyone affected by this issue can get around by adjusting the itemHeight
property and maxSuggestionsInViewPort
But I understand Searchfield should handle that by default.
@maheshmnj can you please point me in a direction for the first bug (most important one) listed above? I'm not sure where or how that happened in the code. Thank you.
@bebaoboy
Just adjust the itemHeight
and maxSuggestionsInViewPort
Form(
key: _formKey,
child: SearchField(
suggestions: _statesOfIndia
.map((e) => SearchFieldListItem(e))
.toList(),
suggestionState: Suggestion.expand,
textInputAction: TextInputAction.next,
hint: 'SearchField Example 2',
searchStyle: TextStyle(
fontSize: 18,
color: Colors.black.withOpacity(0.8),
),
validator: (x) {
if (!_statesOfIndia.contains(x) || x!.isEmpty) {
return 'Please Enter a valid State';
}
return null;
},
searchInputDecoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.black.withOpacity(0.8),
),
),
border: OutlineInputBorder(
borderSide: BorderSide(color: Colors.red),
),
),
maxSuggestionsInViewPort: 6, // adjust the number of Suggestions
itemHeight: 50, // adjusts each suggestionsHeight
onTap: (x) {},
))
@maheshmnj sorry, i mean the code where the suggestion box height is calculating. Because in the first bug, I set maxHeight in view port = 5 but the box shows only 4 suggestions...
Describe the bug There are some bugs when setting the attribute
maxSuggestionsInViewport
.To Reproduce
1. Incorrect Display
I have a simple search field like this with about 16 items.
maxSuggestionsInViewPort
is set to 5 by default. However, the suggestion result in the app does not show 5 item.2. Does not have a lower bound like it says in the document.
But I can still set it to a value smaller than 5. Again the
maxSuggestionsInViewPort
display incorrectly.Suggested Solution: add a lowerbound check.
3. Upper bound?
So I try to set the value to 16, which is the number of my items (supposed to show JKL10 ... as well). This also happens with value that is bigger than the number of items. Result: the suggestion box does not show all my item. Is this an expected behaviour?
[x] By clicking this checkbox, I confirm I am using the latest version of the package found on pub.dev/searchfield and from master branch on this repo. No library file has been edited.
Code sample
Show code sample
```dart SearchField( hint: 'Basic SearchField', maxSuggestionsInViewPort: 16, //<--- trouble initialValue: SearchFieldListItem