buildLeading method

  1. @override
Widget buildLeading(
  1. BuildContext context
)
override

A widget to display before the current query in the AppBar.

Typically an IconButton configured with a BackButtonIcon that exits the search with close. One can also use an AnimatedIcon driven by transitionAnimation, which animates from e.g. a hamburger menu to the back button as the search overlay fades in.

Returns null if no widget should be shown.

See also:

  • AppBar.leading, the intended use for the return value of this method.

Implementation

@override
Widget buildLeading(BuildContext context) {
  return IconButton(
    tooltip: 'Back',
    icon:const Icon(Icons.arrow_back),
    onPressed: () {
      Navigator.pop(context);
    },
  );
}