buildTopAppbarTrailingAction method
- BuildContext context,
- bool showAvatar
An internal method that builds the widget for this action on the Android platform.
This method is called by OudsTopAppBar to render the appropriate Material-style widget based on the action's type. It is not intended to be called directly by application code.
Supported action types:
- OudsTopBarActionType.icon: An icon button, potentially with a badge.
- OudsTopBarActionType.avatar: An
OudsAvatarwidget. - OudsTopBarActionType.widget: The custom widget provided in the configuration.
Parameters:
context: The build context for accessing theme and component tokens.showAvatar: Controls whether the avatar action should be displayed. Iffalse, returns SizedBox.shrink for avatar type. Has no effect on other action types.
Throws:
- UnimplementedError if the action type is not supported for the Material platform.
Implementation
Widget buildTopAppbarTrailingAction(BuildContext context,bool showAvatar) {
final theme = OudsTheme.of(context);
final iconButtonWithBadge =
MergeSemantics(
child: Semantics(
label: contentDescription,
child: BadgeIconButton(
icon: icon,
badge: badge,
onPressed: () {
onActionPressed?.call();
},
),
),
);
switch (type) {
case OudsTopBarActionType.icon:
return iconButtonWithBadge;
case OudsTopBarActionType.avatar :{
return showAvatar
? _buildAvatar(context,theme)
: SizedBox.shrink();
}
case OudsTopBarActionType.widget:
return widget!;
default:
throw UnimplementedError('Type $type not supported for Material');
}
}