OudsTopBarActionConfig class
A configuration object that defines the appearance and behavior of a single action within an OudsTopBar.
Use the provided factory constructors like OudsTopBarActionConfig.icon, or OudsTopBarActionConfig.text to create type-safe and platform-appropriate actions.
Common Parameters (All Platforms)
- type: The type of action from OudsTopBarActionType.
- onActionPressed: Callback invoked when the action is pressed.
- contentDescription: Accessibility description for the action.
- widget: A custom widget to display as the action. This is only used when type is OudsTopBarActionType.widget.
- icon: Path to custom icon asset. This is used when type is OudsTopBarActionType.icon or OudsTopBarActionType.custom.
iOS/Cupertino-Only Parameters
- actionLabel: Text label for the action (used with OudsTopBarActionType.text).
- previousPageTitle: The title of the previous page for back navigation context Behavior:
- When provided with OudsTopBarActionType.back: Displays the back icon followed by this text (e.g., "← Home")
- When null and the type OudsTopBarActionType.back is provided: Displays only the back icon (e.g., "←")
This helps users understand their navigation context by showing where the back action will take them.
Android/Material-Only Parameters
- badge: Configuration for a notification badge. This is only used on Material when type is OudsTopBarActionType.icon.
- avatarConfig: Configuration for an avatar. This is only used on Material when type is OudsTopBarActionType.avatar.
Example of usage
OudsTopBar(
title: "My App",
leadingActions: [
OudsTopBarActionConfig.back(onActionPressed: () => Navigator.pop(context)),
previousPageTitle: 'Settings', // Shows: "← Settings"
],
trailingActions: [
OudsTopBarActionConfig.icon(
icon: 'assets/icons/search.svg',
contentDescription: 'Search',
onActionPressed: () => _handleSearch(),
),
OudsTopBarActionConfig.text(
actionLabel: 'Done',
onActionPressed: () => _handleDone(),
),
],
)
Platform-Specific Considerations
iOS Guidelines
- Use OudsTopBarActionConfig.text for primary actions.
- Keep action labels short (1-2 words).
- A maximum of 3 trailing actions is recommended.
Android Guidelines
- Use OudsTopBarActionConfig.icon for most actions.
- A maximum of 3 trailing actions is recommended.
- Use an overflow menu for additional actions (not directly provided by this component).
See Also
- OudsTopBar - The adaptive top bar component that uses this configuration.
- OudsTopAppBar - The Material Design implementation of the top bar.
- OudsToolbarTop - The Cupertino (iOS) implementation of the top bar.
Constructors
- OudsTopBarActionConfig.avatar({required OudsTopAppBarAvatarConfig avatarConfig, VoidCallback? onActionPressed, String? contentDescription})
-
Creates a configuration for an avatar action.
factory
- OudsTopBarActionConfig.back({String? previousPageTitle, VoidCallback? onActionPressed, String? contentDescription})
-
Creates a configuration for a standard 'back' navigation action.
factory
- OudsTopBarActionConfig.close({String? actionLabel, VoidCallback? onActionPressed, String? contentDescription})
-
Creates a configuration for a close action.
factory
- OudsTopBarActionConfig.custom({required String icon, VoidCallback? onActionPressed, String? contentDescription})
-
Creates a configuration for a custom leading icon-based action.
factory
- OudsTopBarActionConfig.icon({required String icon, VoidCallback? onActionPressed, String? contentDescription, OudsTopAppBarActionBadge? badge})
-
Creates a configuration for an icon-based action.
factory
-
Creates a configuration for a standard 'menu' (hamburger) navigation action.
factory
- OudsTopBarActionConfig.none()
-
Creates a configuration for an empty action, resulting in no visible output.
factory
- OudsTopBarActionConfig.text({required String actionLabel, VoidCallback? onActionPressed, String? contentDescription})
-
Creates a configuration for a text-based action.
factory
- OudsTopBarActionConfig.widget({required Widget widget, VoidCallback? onActionPressed, String? contentDescription})
-
Creates a configuration that displays a custom, developer-defined
widget.factory
Properties
- actionLabel → String?
-
Cupertino-Only Parameters
final
- avatarConfig → OudsTopAppBarAvatarConfig?
-
Material-Only Parameters
final
- badge → OudsTopAppBarActionBadge?
-
final
- contentDescription → String?
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- icon → String?
-
final
- onActionPressed → VoidCallback?
-
final
- previousPageTitle → String?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- type → OudsTopBarActionType
-
Common parameters
final
- widget → Widget?
-
final
Methods
-
buildToolbarTopAction(
BuildContext context, bool isLeadingAction) → Widget - An internal method that builds the widget for this action on the iOS platform.
-
buildTopAppbarTrailingAction(
BuildContext context, bool showAvatar) → Widget - An internal method that builds the widget for this action on the Android platform.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited