EmptyState class

A friendly placeholder for a screen or list that simply has no content yet.

EmptyState(
  icon: Icons.inbox_outlined,
  title: 'No data found',
  message: 'There is nothing to show here yet.',
  actionText: 'Refresh',
  onAction: _reload,
)

The action button only appears when you pass both actionText and onAction.

Inheritance

Constructors

EmptyState({Key? key, IconData? icon = Icons.inbox_outlined, Widget? iconWidget, String? title = 'Nothing here yet', String? message, String? actionText, FutureOr<void> onAction()?, String? secondaryActionText, FutureOr<void> onSecondaryAction()?, Future<void> onRefresh()?, double? iconSize, double? spacing, EdgeInsetsGeometry? padding, double? maxContentWidth, TextAlign? textAlign, Color? iconColor, TextStyle? titleStyle, TextStyle? messageStyle, ButtonStyle? buttonStyle, ButtonStyle? secondaryButtonStyle, bool? animate, Duration? animationDuration})
const

Properties

actionText String?
Label for the action button. The button only shows when both this and onAction are set.
final
animate bool?
Whether to play a subtle fade + slide when the widget first appears. Defaults to true and is skipped automatically when the OS "reduce motion" accessibility setting is on.
final
animationDuration Duration?
How long the entrance animation runs. Falls back to the EmptyStateTheme, then 350ms.
final
buttonStyle ButtonStyle?
Action-button style. Falls back to the EmptyStateTheme, then the FilledButton theme.
final
hashCode int
The hash code for this object.
no setterinherited
icon IconData?
Material icon shown above the text. Ignored when iconWidget is set.
final
iconColor Color?
Icon colour. Falls back to the EmptyStateTheme, then the theme's onSurfaceVariant.
final
iconSize double?
Icon size. Falls back to the EmptyStateTheme, then 72.
final
iconWidget Widget?
A custom illustration to use instead of icon — an image, an SVG, a Lottie animation, anything. Wins over icon when both are set.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxContentWidth double?
Caps the content width so text stays readable on tablets and the web. Falls back to the EmptyStateTheme, then 320.
final
message String?
The supporting line under the title. Pass null to hide it.
final
messageStyle TextStyle?
Message text style. Falls back to the EmptyStateTheme, then the theme's bodyMedium.
final
onAction FutureOr<void> Function()?
Called when the action button is tapped. Returning a Future makes the button disable itself and show an inline progress indicator until the future completes — handy for async retries.
final
onRefresh Future<void> Function()?
Enables pull-to-refresh. When set, the state is wrapped in a RefreshIndicator with an always-scrollable viewport, so the user can pull down to reload even though there's no list on screen.
final
onSecondaryAction FutureOr<void> Function()?
Called when the secondary button is tapped. Behaves like onAction, including the async progress treatment.
final
padding EdgeInsetsGeometry?
Padding around the whole block. Falls back to the EmptyStateTheme, then EdgeInsets.all(24).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
secondaryActionText String?
Label for an optional secondary (text) button under the main action. Only shows when both this and onSecondaryAction are set.
final
secondaryButtonStyle ButtonStyle?
Style for the secondary TextButton. Falls back to the EmptyStateTheme, then the ambient TextButton theme.
final
spacing double?
Vertical gap between the icon, text and button. Falls back to the EmptyStateTheme, then 16.
final
textAlign TextAlign?
Alignment for the title and message. Falls back to the EmptyStateTheme, then TextAlign.center.
final
title String?
The headline. Pass null to hide it.
final
titleStyle TextStyle?
Title text style. Falls back to the EmptyStateTheme, then the theme's titleMedium.
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.
override
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