Commit 7024a6a9 by Rizal Hermawan

refactor : clears hint text after click close on appbar

parent d388ed49
// ignore_for_file: public_member_api_docs
// ignore_for_file: public_member_api_docs, must_be_immutable, doc_directive_has_extra_arguments
part of 'floating_search_bar.dart';
......@@ -12,7 +12,7 @@ typedef OnFocusChangedCallback = void Function(bool isFocused);
/// This can be considered the base Widget for the full
/// [FloatingSearchBar].
class FloatingSearchAppBar extends ImplicitlyAnimatedWidget {
const FloatingSearchAppBar({
FloatingSearchAppBar({
Key? key,
Duration implicitDuration = const Duration(milliseconds: 500),
Curve implicitCurve = Curves.linear,
......@@ -154,7 +154,7 @@ class FloatingSearchAppBar extends ImplicitlyAnimatedWidget {
final Widget? title;
/// {@macro floating_search_bar.hint}
final String? hint;
String? hint;
/// {@macro floating_search_bar.actions}
final List<Widget>? actions;
......@@ -212,15 +212,11 @@ class FloatingSearchAppBarState extends ImplicitlyAnimatedWidgetState<
if (status == AnimationStatus.dismissed) {
if (widget.clearQueryOnClose) {
if (widget.autoRemoveControllerValue == null) {
clear();
} else {
if (widget.autoRemoveControllerValue! == true) {
if (widget.autoRemoveControllerValue == null || widget.autoRemoveControllerValue! == true) {
clear();
}
}
}
}
});
late CurvedAnimation transitionAnimation = CurvedAnimation(
......@@ -382,7 +378,15 @@ class FloatingSearchAppBarState extends ImplicitlyAnimatedWidgetState<
_input.clearFocus();
}
void clear() => _input.clear();
void clear() {
final bool hasQuery = !widget.clearQueryOnClose && query.isNotEmpty;
if (hasQuery == true) {
setState(() {
widget.hint = '';
});
}
_input.clear();
}
void _assignController() => widget.controller?._appBarState = this;
......
// ignore_for_file: doc_directive_has_extra_arguments
import 'dart:math';
import 'dart:ui';
......
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