MaterialBanner class Null safety

A Material Design banner.

A banner displays an important, succinct message, and provides actions for users to address (or dismiss the banner). A user action is required for it to be dismissed.

Banners should be displayed at the top of the screen, below a top app bar. They are persistent and non-modal, allowing the user to either ignore them or interact with them at any time.

To create a local project with this code sample, run:
flutter create --sample=material.MaterialBanner.1 mysample

The actions will be placed beside the content if there is only one. Otherwise, the actions will be placed below the content. Use forceActionsBelow to override this behavior.

If the actions placed below the content, they will be laid out in a row. If there isn't sufficient room to display everything, they are laid out in a column instead.

The actions and content must be provided. An optional leading widget (typically an Image) can also be provided. The contentTextStyle and backgroundColor can be provided to customize the banner.

This widget is unrelated to the widgets library Banner widget.

Inheritance

Constructors

MaterialBanner({Key? key, required Widget content, TextStyle? contentTextStyle, required List<Widget> actions, Widget? leading, Color? backgroundColor, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? leadingPadding, bool forceActionsBelow, OverflowBarAlignment overflowAlignment})
Creates a MaterialBanner. [...]
const

Properties

actions List<Widget>
The set of actions that are displayed at the bottom or trailing side of the MaterialBanner. [...]
final
backgroundColor Color?
The color of the surface of this MaterialBanner. [...]
final
content Widget
The content of the MaterialBanner. [...]
final
contentTextStyle TextStyle?
Style for the text in the content of the MaterialBanner. [...]
final
forceActionsBelow bool
An override to force the actions to be below the content regardless of how many there are. [...]
final
hashCode int
The hash code for this object. [...]
@nonVirtual, read-only, inherited
key Key?
Controls how one widget replaces another widget in the tree. [...]
final, inherited
leading Widget?
The (optional) leading widget of the MaterialBanner. [...]
final
leadingPadding EdgeInsetsGeometry?
The amount of space by which to inset the leading widget. [...]
final
overflowAlignment OverflowBarAlignment
The horizontal alignment of the actions when the actions laid out in a column. [...]
final
padding EdgeInsetsGeometry?
The amount of space by which to inset the content. [...]
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

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. [...]
@protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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}) 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. [...]
@nonVirtual, inherited