buildLeading static method
Implementation
static Widget buildLeading(
BuildContext context,
NavigationAppBar appBar, [
bool imply = true,
]) {
final ModalRoute<dynamic>? parentRoute = ModalRoute.of(context);
final bool canPop = parentRoute?.canPop ?? false;
late Widget widget;
if (appBar.leading != null) {
widget = Padding(
padding: EdgeInsets.only(left: 12.0),
child: appBar.leading,
);
} else if (appBar.automaticallyImplyLeading && imply) {
final onPressed = canPop ? () => Navigator.maybePop(context) : null;
widget = Align(
alignment: Alignment.centerLeft,
child: SizedBox(
width: _kCompactNavigationPanelWidth,
child: IconButton(
icon: Icon(FluentIcons.back, size: 18.0),
onPressed: onPressed,
style: ButtonStyle(
backgroundColor: ButtonState.resolveWith((states) {
if (states.isNone || states.isDisabled)
return Colors.transparent;
return ButtonThemeData.uncheckedInputColor(
FluentTheme.of(context),
states,
);
}),
foregroundColor: ButtonState.resolveWith((states) {
if (states.isDisabled)
return ButtonThemeData.buttonColor(
FluentTheme.of(context).brightness,
states,
);
return ButtonThemeData.uncheckedInputColor(
FluentTheme.of(context),
states,
).basedOnLuminance();
}),
),
),
),
);
if (canPop)
widget = Tooltip(
message: FluentLocalizations.of(context).backButtonTooltip,
child: widget,
);
} else {
return SizedBox.shrink();
}
widget = SizedBox(width: _kCompactNavigationPanelWidth, child: widget);
return widget;
}