Skip to content

Commit 5e8410e

Browse files
committed
Merge branch 'dev'
2 parents f0f4a93 + 7e269cc commit 5e8410e

File tree

8 files changed

+82
-38
lines changed

8 files changed

+82
-38
lines changed

CHANGELOG.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### [1.3.2] - May 23, 2025
2+
3+
- Add SearchInputDecoration.hint and SearchInputDecoration.maintainHintSize (Supports Flutter 3.32)
4+
- hint is deprecated, Use SearchInputDecoration.hintText instead.
5+
16
### [1.3.1] - May 16, 2025
27

38
- Fix [Issue: #231](https://github.com/maheshj01/searchfield/issues/232) Overlay rebuild on window resize was slow
@@ -12,17 +17,31 @@
1217
- Fix [Issue: #212](https://github.com/maheshj01/searchfield/issues/212) add new parameter `keepSearchOnSelection`
1318
- Fix [Issue: #228](https://github.com/maheshj01/searchfield/issues/212) add value parameter to searchfield list item
1419

15-
### [1.2.8] - May 03, 2025
20+
### [1.3.0-dev.5] - May 03, 2025
21+
22+
- Fix [Issue: #218](https://github.com/maheshj01/searchfield/issues/218) FocusNode listener is not removed
23+
24+
### [1.3.0-dev.4] - May 03, 2025
1625

1726
- Fix [Issue: #222](https://github.com/maheshj01/searchfield/issues/222) Suggestion overlay dimensions not updated on resize
1827
- Fix [Issue: #224](https://github.com/maheshj01/searchfield/issues/224) calling setState in listener caused setState exception
28+
- Add VisualDensity Parameter to SearchInputDecoration
1929
- Fix [Issue: #218](https://github.com/maheshj01/searchfield/issues/218) FocusNode listener is not removed
2030

21-
### [1.2.7] - Apr 16, 2025
31+
### [1.3.0-dev.3] - Apr 16, 2025
2232

2333
- Allow onSearchTextChanged to serve Future [Issue #215](https://github.com/maheshj01/searchfield/issues/215)
2434
- Dynamic height is broken when the suggestion direction is up [Issue #216](https://github.com/maheshj01/searchfield/issues/216)
2535

36+
### [1.3.0-dev.2] - Apr 12, 2025
37+
38+
- allow onSearchTextChanged to serve Future [Issue #215](https://github.com/maheshj01/searchfield/issues/215)
39+
40+
### [1.3.0-dev.1] - Mar 19, 2025
41+
42+
- Deprecate `maintainHintHeight` in favour of `maintainHintSize` property of `SearchInputDecoration`
43+
- Add `hint` property to `SearchInputDecoration`
44+
2645
### [1.2.6] - Mar 11, 2025
2746

2847
- Fix Range Error on First Suggestion Tap [Issue #210](https://github.com/maheshj01/searchfield/issues/210)

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,16 @@ This part is mainly applicable to the maintainer of the repository but you are w
4646
- ✅ Publish the package by running `flutter pub publish --dry-run` and `flutter pub publish`
4747
- Update Min Flutter Sdk Constraints in pubspec.yaml, if a new flutter API is used and mention the version in the changelog.
4848
- ✅ Tag the release in github with the version number.
49+
50+
51+
#### Versioning
52+
53+
This project follows [Semantic Versioning](https://semver.org/). The version X.Y.Z indicates:
54+
55+
- X is the major version (backward-incompatible),
56+
- Y is the minor version (backward-compatible), and
57+
- Z is the patch version (backward-compatible bug fix).
58+
59+
This package has two versions:
60+
- Stable version: Compatible with the latest stable version of Flutter.
61+
- Pre-release version: Compatible with the latest master/beta version of Flutter generally used for testing purposes.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [searchfield: ^1.3.1](https://pub.dev/packages/searchfield)
1+
# [searchfield: ^1.3.2](https://pub.dev/packages/searchfield)
22

33
<a href="https://github.com/maheshj01/searchfield" rel="noopener" target="_blank"><img src="https://img.shields.io/badge/platform-flutter-ff69b4.svg" alt="Flutter Platform Badge"></a>
44
<a href="https://pub.dev/packages/searchfield"><img src="https://img.shields.io/pub/v/searchfield.svg" alt="Pub"></a>

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ class _SearchFieldSampleState extends State<SearchFieldSample> {
106106
borderRadius: BorderRadius.all(Radius.circular(2)),
107107
itemPadding: EdgeInsets.symmetric(horizontal: 16),
108108
),
109-
hint: 'Search for a city or zip code',
110109
maxSuggestionBoxHeight: 300,
111110
onSuggestionTap: (SearchFieldListItem<City> item) {
112111
setState(() {
113112
selectedValue = item;
114113
});
115114
},
116115
searchInputDecoration: SearchInputDecoration(
116+
hintText: 'Search for a city or zip code',
117117
prefixIcon: Icon(Icons.search),
118118
suffix: Icon(Icons.expand_more),
119119
border: OutlineInputBorder(

lib/src/input_decoration.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,13 @@ class SearchInputDecoration extends InputDecoration {
8383
super.suffixIcon,
8484
super.suffix,
8585
super.label,
86+
@Deprecated(
87+
'Use maintainHintSize instead. '
88+
'This will maintain both hint height and hint width. '
89+
'This feature was deprecated after v1.26.0',
90+
)
8691
super.maintainHintHeight,
92+
super.maintainHintSize,
8793
super.suffixIconColor,
8894
super.prefix,
8995
super.prefixIconColor,
@@ -94,6 +100,7 @@ class SearchInputDecoration extends InputDecoration {
94100
super.disabledBorder,
95101
super.contentPadding,
96102
super.hintText,
103+
super.hint,
97104
super.hintStyle,
98105
super.labelText,
99106
super.labelStyle,
@@ -161,6 +168,7 @@ class SearchInputDecoration extends InputDecoration {
161168
InputBorder? focusedBorder,
162169
InputBorder? focusedErrorBorder,
163170
Widget? helper,
171+
Widget? hint,
164172
int? helperMaxLines,
165173
TextStyle? helperStyle,
166174
String? helperText,
@@ -191,9 +199,11 @@ class SearchInputDecoration extends InputDecoration {
191199
BoxConstraints? suffixIconConstraints,
192200
TextStyle? suffixStyle,
193201
String? suffixText,
202+
bool? maintainHintSize,
194203
}) {
195204
return SearchInputDecoration(
196205
maintainHintHeight: maintainHintHeight ?? this.maintainHintHeight,
206+
maintainHintSize: maintainHintSize ?? this.maintainHintSize,
197207
cursorColor: cursorColor ?? this.cursorColor,
198208
textCapitalization: textCapitalization ?? this.textCapitalization,
199209
searchStyle: searchStyle ?? this.searchStyle,
@@ -206,6 +216,7 @@ class SearchInputDecoration extends InputDecoration {
206216
errorText: errorText ?? this.errorText,
207217
error: error ?? this.error,
208218
hintTextDirection: hintTextDirection ?? this.hintTextDirection,
219+
hint: hint ?? this.hint,
209220
hintFadeDuration: hintFadeDuration ?? this.hintFadeDuration,
210221
helper: helper ?? this.helper,
211222
cursorErrorColor: cursorErrorColor ?? this.cursorErrorColor,

lib/src/searchfield.dart

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ class SearchField<T> extends StatefulWidget {
317317
this.emptyWidget = const SizedBox(),
318318
this.enabled,
319319
this.focusNode,
320+
@Deprecated(
321+
'Use SearchInputDecoration.hintText instead.',
322+
)
320323
this.hint,
321324
this.selectedValue,
322325
this.inputFormatters,
@@ -415,32 +418,7 @@ class _SearchFieldState<T> extends State<SearchField<T>> {
415418
} else {
416419
_searchFocus = FocusNode();
417420
}
418-
_searchFocus!.addListener(() {
419-
// When focus shifts to ListView prevent suggestions from rebuilding
420-
// when user navigates through suggestions using keyboard
421-
if (_searchFocus!.hasFocus) {
422-
if (searchController!.text.isNotEmpty) {
423-
highlightIndex = widget.suggestions
424-
.indexWhere((element) => element == widget.selectedValue);
425-
}
426-
_overlayEntry ??= _createOverlay();
427-
if (widget.suggestionState == Suggestion.expand) {
428-
isSuggestionsShown = true;
429-
Future.delayed(Duration(milliseconds: 100), () {
430-
suggestionStream.sink.add(widget.suggestions);
431-
});
432-
}
433-
Overlay.of(context).insert(_overlayEntry!);
434-
} else {
435-
removeOverlay();
436-
if (_suggestionDirection == SuggestionDirection.up) {
437-
highlightIndex = length;
438-
} else {
439-
highlightIndex = -1;
440-
}
441-
suggestionStream.sink.add(null);
442-
}
443-
});
421+
_searchFocus?.addListener(_handleFocusChange);
444422
}
445423

446424
/// With SuggestionDirection.flex, the widget will automatically decide the direction of the
@@ -474,6 +452,33 @@ class _SearchFieldState<T> extends State<SearchField<T>> {
474452
}
475453
}
476454

455+
void _handleFocusChange() {
456+
// When focus shifts to ListView prevent suggestions from rebuilding
457+
// when user navigates through suggestions using keyboard
458+
if (_searchFocus!.hasFocus) {
459+
if (searchController!.text.isNotEmpty) {
460+
highlightIndex = widget.suggestions
461+
.indexWhere((element) => element == widget.selectedValue);
462+
}
463+
_overlayEntry ??= _createOverlay();
464+
if (widget.suggestionState == Suggestion.expand) {
465+
isSuggestionsShown = true;
466+
Future.delayed(Duration(milliseconds: 100), () {
467+
suggestionStream.sink.add(widget.suggestions);
468+
});
469+
}
470+
Overlay.of(context).insert(_overlayEntry!);
471+
} else {
472+
removeOverlay();
473+
if (_suggestionDirection == SuggestionDirection.up) {
474+
highlightIndex = length;
475+
} else {
476+
highlightIndex = -1;
477+
}
478+
suggestionStream.sink.add(null);
479+
}
480+
}
481+
477482
double _getSuggestionsHeight(Size screenSize) {
478483
return _totalHeight ??
479484
widget.maxSuggestionBoxHeight ??
@@ -917,11 +922,6 @@ class _SearchFieldState<T> extends State<SearchField<T>> {
917922
OverlayEntry _createOverlay() {
918923
return OverlayEntry(builder: (context) {
919924
_totalHeight = widget.maxSuggestionsInViewPort * widget.itemHeight;
920-
// final textFieldRenderBox =
921-
// key.currentContext!.findRenderObject() as RenderBox;
922-
// final textFieldsize = textFieldRenderBox.size;
923-
// final offset = textFieldRenderBox.localToGlobal(Offset.zero);
924-
// var yOffset = Offset.zero;
925925
return LayoutBuilder(
926926
builder: (BuildContext context, BoxConstraints constraints) {
927927
_calculateDimensions();

pubspec.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name: searchfield
22
description: A highly customizable, simple and easy to use AutoComplete widget for your Flutter app
3-
version: 1.3.1
3+
version: 1.3.2
44
homepage: https://github.com/maheshj01/searchfield
55
repository: https://github.com/maheshj01/searchfield
66
issue_tracker: https://github.com/maheshj01/searchfield/issues
7-
7+
funding:
8+
- https://github.com/sponsors/maheshj01/
89
environment:
910
sdk: ">=3.3.0 <4.0.0"
1011
flutter: ">=3.27.0"

test/searchfield_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2254,6 +2254,6 @@ void main() {
22542254
expect(overlayFinder, findsOneWidget);
22552255
expect(overlaySize.width, closeTo(logicalWidth, 0.1));
22562256
});
2257-
2257+
22582258
// todo: add test for `keepSearchOnSelection`
22592259
}

0 commit comments

Comments
 (0)