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

Refactor: Overlay condition too strict #185

Merged
merged 4 commits into from
Oct 22, 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#### [1.1.7] - October 22, 2024
- Refactor: Overlay condition too strict [Issue: 182](https://github.com/maheshj01/searchfield/issues/182)

#### [1.1.6] - September 25, 2024
- Fix: new properties were missing in CopyWith Constructor [Issue: 177 comment](https://github.com/maheshj01/searchfield/issues/177#issuecomment-2376401417)

#### [1.1.5] - September 25, 2024

- remove custom assertions for `SearchInputDecoration` properties
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [searchfield: ^1.1.5](https://pub.dev/packages/searchfield)
# [searchfield: ^1.1.7](https://pub.dev/packages/searchfield)

<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>
<a href="https://pub.dev/packages/searchfield"><img src="https://img.shields.io/pub/v/searchfield.svg" alt="Pub"></a>
Expand Down
16 changes: 15 additions & 1 deletion lib/src/input_decoration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class SearchInputDecoration extends InputDecoration {
super.errorStyle,
super.suffixIconConstraints,
});

@override
SearchInputDecoration copyWith({
Key? key,
Expand Down Expand Up @@ -191,6 +191,20 @@ class SearchInputDecoration extends InputDecoration {
String? suffixText,
}) {
return SearchInputDecoration(
cursorColor: cursorColor ?? this.cursorColor,
textCapitalization: textCapitalization ?? this.textCapitalization,
searchStyle: searchStyle ?? this.searchStyle,
prefixIconConstraints:
prefixIconConstraints ?? this.prefixIconConstraints,
suffixIconConstraints:
suffixIconConstraints ?? this.suffixIconConstraints,
hintMaxLines: hintMaxLines ?? this.hintMaxLines,
floatingLabelStyle: floatingLabelStyle ?? this.floatingLabelStyle,
errorText: errorText ?? this.errorText,
error: error ?? this.error,
hintTextDirection: hintTextDirection ?? this.hintTextDirection,
hintFadeDuration: hintFadeDuration ?? this.hintFadeDuration,
helper: helper ?? this.helper,
cursorErrorColor: cursorErrorColor ?? this.cursorErrorColor,
cursorHeight: cursorHeight ?? this.cursorHeight,
cursorWidth: cursorWidth ?? this.cursorWidth,
Expand Down
7 changes: 5 additions & 2 deletions lib/src/searchfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ class _SearchFieldState<T> extends State<SearchField<T>> {
// When focus shifts to ListView prevent suggestions from rebuilding
// when user navigates through suggestions using keyboard
if (_searchFocus!.hasFocus) {
_overlayEntry ??= _createOverlay();
_overlayEntry = _createOverlay();
if (widget.suggestionState == Suggestion.expand) {
isSuggestionsShown = true;
Future.delayed(Duration(milliseconds: 100), () {
Expand Down Expand Up @@ -866,15 +866,17 @@ class _SearchFieldState<T> extends State<SearchField<T>> {
return null;
}

Widget? _streamBuilder;
OverlayEntry _createOverlay() {
return OverlayEntry(builder: (context) {
if (_streamBuilder != null) return _streamBuilder!;
final textFieldRenderBox =
key.currentContext!.findRenderObject() as RenderBox;
final textFieldsize = textFieldRenderBox.size;
final offset = textFieldRenderBox.localToGlobal(Offset.zero);
var yOffset = Offset.zero;
_totalHeight = widget.maxSuggestionsInViewPort * widget.itemHeight;
return StreamBuilder<List<SearchFieldListItem?>?>(
_streamBuilder = StreamBuilder<List<SearchFieldListItem?>?>(
stream: suggestionStream.stream,
builder: (BuildContext context,
AsyncSnapshot<List<SearchFieldListItem?>?> snapshot) {
Expand All @@ -900,6 +902,7 @@ class _SearchFieldState<T> extends State<SearchField<T>> {
),
);
});
return _streamBuilder!;
});
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: searchfield
description: A highly customizable, simple and easy to use flutter Widget to add a searchfield to your Flutter Application. This Widget allows you to search and select from list of suggestions.
version: 1.1.5
version: 1.1.7
homepage: https://github.com/maheshj01/searchfield
repository: https://github.com/maheshj01/searchfield
issue_tracker: https://github.com/maheshj01/searchfield/issues
Expand Down
Loading