Commit 62865899 by Rizal Hermawan

refactor : add custom functions inside FloatingSearchBarAction

parent c724d3a1
......@@ -20,6 +20,8 @@ class FloatingSearchBarAction extends StatelessWidget {
this.builder,
this.showIfOpened = false,
this.showIfClosed = true,
this.runCustomFunction = false,
this.customFunction
}) : assert(builder != null || child != null);
/// A hamburger menu that when tapped opens the [Drawer]
......@@ -81,6 +83,8 @@ class FloatingSearchBarAction extends StatelessWidget {
Duration duration = const Duration(milliseconds: 900),
String searchButtonSemanticLabel = 'Search',
String clearButtonSemanticLabel = 'Clear',
bool runCustomFunction = false,
void Function()? customFunction,
}) {
return FloatingSearchBarAction(
showIfOpened: true,
......@@ -101,6 +105,9 @@ class FloatingSearchBarAction extends StatelessWidget {
onTap: () {
if (!isEmpty) {
bar.clear();
if (runCustomFunction == true) {
customFunction!;
}
} else {
bar.isOpen =
!bar.isOpen || (!bar.hasFocus && bar.isAlwaysOpened);
......@@ -196,6 +203,10 @@ class FloatingSearchBarAction extends StatelessWidget {
/// and when closed.
bool get isAlwaysShown => showIfOpened && showIfClosed;
final bool runCustomFunction;
final void Function()? customFunction;
@override
Widget build(BuildContext context) {
return child ??
......
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