PlatformAppBar class

A platform-adaptive app bar that renders Material AppBar on Android and CupertinoNavigationBar on iOS.

This widget automatically selects the appropriate app bar implementation based on the target platform:

  • On Android: renders Material Design AppBar
  • On iOS: renders CupertinoNavigationBar

The app bar can be configured with platform-specific data through materialAppBarData and cupertinoNavigationBarData, or with common properties.

Example:

PlatformAppBar(
  title: Text('My App'),
  leading: IconButton(
    icon: Icon(Icons.menu),
    onPressed: () => Scaffold.of(context).openDrawer(),
  ),
)
Implemented types

Constructors

PlatformAppBar({Key? widgetKey, MaterialAppBarData? materialAppBarData, CupertinoNavigationBarData? cupertinoNavigationBarData, Widget? title, Color? backgroundColor, Widget? leading, bool automaticallyImplyLeading = kAutoImplyLeading, PreferredSizeWidget? bottom})
Creates a platform-adaptive app bar.
const

Properties

automaticallyImplyLeading bool
Whether to automatically imply a leading widget.
final
backgroundColor Color?
Background color of the app bar.
final
bottom PreferredSizeWidget?
Widget to display below the app bar.
final
cupertinoNavigationBarData CupertinoNavigationBarData?
Cupertino-specific navigation bar data.
final
hashCode int
The hash code for this object.
no setterinherited
leading Widget?
Widget to display before the title.
final
materialAppBarData MaterialAppBarData?
Material-specific app bar data.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
title Widget?
The primary title of the app bar.
final
widgetKey Key?
Optional key for the app bar widget.
final

Methods

cupertinoBuilder(BuildContext context) ObstructingPreferredSizeWidget
Builds a Cupertino ObstructingPreferredSizeWidget for iOS.
override
materialBuilder(BuildContext context) PreferredSizeWidget
Builds a Material PreferredSizeWidget for Android.
override
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