leading property
A widget to display before the title.
If this is null and automaticallyImplyLeading is set to true, the NewGradientAppBar will imply an appropriate widget. For example, if the NewGradientAppBar is in a Scaffold that also has a Drawer, the Scaffold will fill this widget with an IconButton that opens the drawer (using Icons.menu). If there's no Drawer and the parent Navigator can go back, the NewGradientAppBar will use a BackButton that calls Navigator.maybePop.
{@tool sample}
The following code shows how the drawer button could be manually specified instead of relying on automaticallyImplyLeading:
GradientAppBar(
leading: Builder(
builder: (BuildContext context) {
return IconButton(
icon: const Icon(Icons.menu),
onPressed: () { Scaffold.of(context).openDrawer(); },
tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,
);
},
),
)
{@end-tool}
The Builder is used in this example to ensure that the context
refers
to that part of the subtree. That way this code snippet can be used even
inside the very code that is creating the Scaffold (in which case,
without the Builder, the context
wouldn't be able to see the
Scaffold, since it would refer to an ancestor of that widget).
See also:
- Scaffold.appBar, in which an NewGradientAppBar is usually placed.
- Scaffold.drawer, in which the Drawer is usually placed.
Implementation
final Widget? leading;