OudsTopBar class

A platform-adaptive top app bar that displays information and actions relating to the current screen.

Reference design version : 1.0.0

The Bar top is a top-aligned component that displays the screen title and provides access to key actions and navigation elements.

OudsTopBar is a high-level component that provides a consistent top bar experience across platforms by rendering the appropriate underlying widget:

This abstraction allows you to define your app bar once, with the component handling the platform-specific rendering details.

Parameters:

Common parameters

  • title: The title to be displayed in the top bar.

  • size: The size of the Bar Top defined by OudsTopBarSize.

    • Medium size is only supported in the Material variant.
  • translucent: Whether the Bar Top should be translucent.

  • leadingActions: A list of actions to display before the title.

    • Material: Supports a single leading action.
    • Cupertino: Supports multiple leading actions.
  • trailingActions: A list of actions to display at the end of the Bar Top. These can be type of OudsTopBarActionConfig. The default layout here is a Row, so actions will be placed horizontally. The maximum recommended number of actions is three, it list of OudsTopBarActionConfig, Please use a dropdown menu if you need more than three actions.

Material variant only (ignored on Cupertino)

-materialConfig: This parameter is only applied on Material and other non-iOS platforms where the widget renders an OudsTopAppBar. Use this to control Material-only features like centerTitle or expandedHeight. See OudsTopAppBarConfig. It is ignored on iOS.

Use an OudsTopAppBarConfig object to control Material-specific features such as:

  • Centering the title (centerTitle).
  • Setting a custom expanded height (expandedHeight).
  • Specifying the maximum number of lines for the title (titleMaxLines).
  • Enabling avatar support (showAvatar).

Example usage:

The following example shows a simple OudsTopBar with a back button and a trailing search action.

Scaffold(
  appBar: OudsTopBar(
    title: "My Screen",
    leadingActions: [
      OudsTopBarActionConfig.back(
        onActionPressed: () => Navigator.of(context).pop(),
      ),
    ],
    trailingActions: [
      OudsTopBarActionConfig.icon(
        customIcon: "assets/icons/search.svg",
        contentDescription: "Search",
        onActionPressed: () {
          // Handle search action
        },
      ),
    ],
  ),
  body: // ...
)

Platform Differences

  • Leading Actions: The Material AppBar typically has a single leading action (e.g., a navigation icon). The Cupertino CupertinoNavigationBar can support multiple leading actions. This widget enforces a single leading action on Android to align with Material Design guidelines.

  • Size: The medium and large sizes create an expandable AppBar on Android. On iOS, medium is treated as small.

See also:

Inheritance
Implemented types

Constructors

OudsTopBar({Key? key, String? title, bool translucent = false, OudsTopBarSize size = OudsTopBarSize.small, List<OudsTopBarActionConfig>? leadingActions, List<OudsTopBarActionConfig>? trailingActions, OudsTopAppBarConfig? materialConfig})
const

Properties

hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
leadingActions List<OudsTopBarActionConfig>?
final
materialConfig OudsTopAppBarConfig?
Platform-specific configuration for Material (Android).
final
preferredSize Size
Returns the preferred size based on the platform: OudsToolbarTop size for iOS, OudsTopAppBar size for Android and other platforms.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size OudsTopBarSize
final
title String?
Common parameters
final
trailingActions List<OudsTopBarActionConfig>?
final
translucent bool
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

getPreferredSize({OudsTopBarSize? size, double? expandedHeight}) Size
Returns the preferred size based on the platform: OudsToolbarTop size for iOS, OudsTopAppBar size for Android and other platforms.