Commit b9a51039 by Rizal Hermawan

refactor : add a property so that textinput search does not automatically disappear

parent fd8cad15
......@@ -54,6 +54,7 @@ class FloatingSearchAppBar extends ImplicitlyAnimatedWidget {
this.autocorrect = true,
this.contextMenuBuilder,
this.onKeyEvent,
this.autoRemoveControllerValue
}) : assert(progress == null || (progress is num || progress is bool)),
super(key, implicitDuration, implicitCurve);
......@@ -191,6 +192,8 @@ class FloatingSearchAppBar extends ImplicitlyAnimatedWidget {
return context.findAncestorStateOfType<FloatingSearchAppBarState>();
}
final bool? autoRemoveControllerValue;
@override
FloatingSearchAppBarState createState() => FloatingSearchAppBarState();
}
......@@ -209,7 +212,13 @@ class FloatingSearchAppBarState extends ImplicitlyAnimatedWidgetState<
if (status == AnimationStatus.dismissed) {
if (widget.clearQueryOnClose) {
clear();
if (widget.autoRemoveControllerValue == null) {
clear();
} else {
if (widget.autoRemoveControllerValue! == true) {
clear();
}
}
}
}
});
......
......@@ -82,6 +82,7 @@ class FloatingSearchBar extends ImplicitlyAnimatedWidget {
this.showCursor = true,
bool initiallyHidden = false,
this.onKeyEvent,
this.autoRemoveControllerValue,
}) : showAfter =
showAfter ?? (initiallyHidden ? const Duration(days: 1) : null),
super(key, implicitDuration, implicitCurve);
......@@ -407,6 +408,8 @@ class FloatingSearchBar extends ImplicitlyAnimatedWidget {
/// this `FloatingSearchBar`.
final EdgeInsets scrollPadding;
final bool? autoRemoveControllerValue;
@override
FloatingSearchBarState createState() => FloatingSearchBarState();
......@@ -766,6 +769,7 @@ class FloatingSearchBarState extends ImplicitlyAnimatedWidgetState<
titleStyle: widget.queryStyle,
shadowColor: style.shadowColor,
onKeyEvent: widget.onKeyEvent,
autoRemoveControllerValue: widget.autoRemoveControllerValue,
);
return SizedBox.expand(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment