buildTopAppbarTrailingAction method

Widget buildTopAppbarTrailingAction(
  1. BuildContext context,
  2. 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:

Parameters:

  • context: The build context for accessing theme and component tokens.
  • showAvatar: Controls whether the avatar action should be displayed. If false, returns SizedBox.shrink for avatar type. Has no effect on other action types.

Throws:

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');
  }
}