FloatingSearchBarAction.hamburgerToBack constructor
A hamburger menu that when tapped opens the Drawer of the nearest Scaffold.
When the FloatingSearchBar opens, the hamburger transitions into a back button.
Implementation
factory FloatingSearchBarAction.hamburgerToBack({
double size = 24,
Color? color,
bool isLeading = true,
}) {
return FloatingSearchBarAction(
showIfOpened: true,
builder: (context, animation) {
final isLTR = Directionality.of(context) == TextDirection.ltr;
return AnimatedBuilder(
child: RotatedBox(
quarterTurns: (isLTR ? 0 : 2) + (isLeading ? 0 : 2),
child: AnimatedIcon(
icon: AnimatedIcons.menu_arrow,
// Menu arrow has some weird errors on LTR...
// Always use LTR and rotate the widget manually
// for now.
textDirection: TextDirection.ltr,
progress: animation,
color: color,
size: size,
),
),
animation: animation,
builder: (context, icon) => CircularButton(
tooltip: animation.isDismissed
? MaterialLocalizations.of(context).openAppDrawerTooltip
: MaterialLocalizations.of(context).backButtonTooltip,
onPressed: () {
final bar = FloatingSearchAppBar.of(context);
if (bar?.isOpen == true) {
bar?.close();
} else {
Scaffold.of(context).openDrawer();
}
},
icon: icon!,
),
);
},
);
}