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 { ...@@ -54,6 +54,7 @@ class FloatingSearchAppBar extends ImplicitlyAnimatedWidget {
this.autocorrect = true, this.autocorrect = true,
this.contextMenuBuilder, this.contextMenuBuilder,
this.onKeyEvent, this.onKeyEvent,
this.autoRemoveControllerValue
}) : assert(progress == null || (progress is num || progress is bool)), }) : assert(progress == null || (progress is num || progress is bool)),
super(key, implicitDuration, implicitCurve); super(key, implicitDuration, implicitCurve);
...@@ -191,6 +192,8 @@ class FloatingSearchAppBar extends ImplicitlyAnimatedWidget { ...@@ -191,6 +192,8 @@ class FloatingSearchAppBar extends ImplicitlyAnimatedWidget {
return context.findAncestorStateOfType<FloatingSearchAppBarState>(); return context.findAncestorStateOfType<FloatingSearchAppBarState>();
} }
final bool? autoRemoveControllerValue;
@override @override
FloatingSearchAppBarState createState() => FloatingSearchAppBarState(); FloatingSearchAppBarState createState() => FloatingSearchAppBarState();
} }
...@@ -209,7 +212,13 @@ class FloatingSearchAppBarState extends ImplicitlyAnimatedWidgetState< ...@@ -209,7 +212,13 @@ class FloatingSearchAppBarState extends ImplicitlyAnimatedWidgetState<
if (status == AnimationStatus.dismissed) { if (status == AnimationStatus.dismissed) {
if (widget.clearQueryOnClose) { if (widget.clearQueryOnClose) {
clear(); if (widget.autoRemoveControllerValue == null) {
clear();
} else {
if (widget.autoRemoveControllerValue! == true) {
clear();
}
}
} }
} }
}); });
......
...@@ -82,6 +82,7 @@ class FloatingSearchBar extends ImplicitlyAnimatedWidget { ...@@ -82,6 +82,7 @@ class FloatingSearchBar extends ImplicitlyAnimatedWidget {
this.showCursor = true, this.showCursor = true,
bool initiallyHidden = false, bool initiallyHidden = false,
this.onKeyEvent, this.onKeyEvent,
this.autoRemoveControllerValue,
}) : showAfter = }) : showAfter =
showAfter ?? (initiallyHidden ? const Duration(days: 1) : null), showAfter ?? (initiallyHidden ? const Duration(days: 1) : null),
super(key, implicitDuration, implicitCurve); super(key, implicitDuration, implicitCurve);
...@@ -407,6 +408,8 @@ class FloatingSearchBar extends ImplicitlyAnimatedWidget { ...@@ -407,6 +408,8 @@ class FloatingSearchBar extends ImplicitlyAnimatedWidget {
/// this `FloatingSearchBar`. /// this `FloatingSearchBar`.
final EdgeInsets scrollPadding; final EdgeInsets scrollPadding;
final bool? autoRemoveControllerValue;
@override @override
FloatingSearchBarState createState() => FloatingSearchBarState(); FloatingSearchBarState createState() => FloatingSearchBarState();
...@@ -766,6 +769,7 @@ class FloatingSearchBarState extends ImplicitlyAnimatedWidgetState< ...@@ -766,6 +769,7 @@ class FloatingSearchBarState extends ImplicitlyAnimatedWidgetState<
titleStyle: widget.queryStyle, titleStyle: widget.queryStyle,
shadowColor: style.shadowColor, shadowColor: style.shadowColor,
onKeyEvent: widget.onKeyEvent, onKeyEvent: widget.onKeyEvent,
autoRemoveControllerValue: widget.autoRemoveControllerValue,
); );
return SizedBox.expand( 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