CustomEmptyWidget class
A highly customizable empty state widget for displaying "no content" scenarios.
This widget provides a flexible solution for showing empty states throughout the CulicidaeLab application. It supports various customization options including custom images, text styling, and complete widget replacement for maximum flexibility.
Design Philosophy
Empty states are crucial for user experience as they:
- Provide clear feedback when no content is available
- Guide users on what actions they can take
- Maintain visual consistency across the application
- Prevent confusion and improve usability
Usage Scenarios
- Search Results: When no mosquito species match search criteria
- Gallery Loading: While species data is being fetched
- Classification: When no image has been selected yet
- Disease Information: When no diseases are associated with a species
- Network Errors: When data cannot be loaded from remote sources
Customization Options
The widget supports multiple levels of customization:
- Standard: Use predefined image, title, and subtitle
- Styled: Apply custom text styles and formatting
- Widget-based: Replace image with custom widget (icons, illustrations)
- Complete Override: Use entirely custom widget for unique layouts
Example Usage
// Basic usage with text only
CustomEmptyWidget(
title: 'No mosquito species found',
subtitle: 'Try adjusting your search criteria',
)
// With custom image and styling
CustomEmptyWidget(
title: 'No classification results',
subtitle: 'Please select an image to analyze',
image: 'assets/images/empty_classification.png',
titleTextStyle: TextStyle(fontSize: 20, color: Colors.teal),
)
// With custom icon widget
CustomEmptyWidget(
title: 'No diseases found',
imageWidget: Icon(Icons.health_and_safety, size: 64, color: Colors.grey),
)
Accessibility
The widget follows accessibility best practices:
- Proper semantic structure for screen readers
- Sufficient color contrast for text elements
- Scalable text that respects user font size preferences
- Meaningful content descriptions
See also:
- CustomEmptyWidgetHelper for utility functions
- Material Design guidelines for empty states
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- CustomEmptyWidget
Constructors
- CustomEmptyWidget({Key? key, String? title, String? subtitle, String? image, String? packageImage, Widget? customWidget, Widget? imageWidget, bool hideTitle = false, bool hideSubTitle = false, TextStyle? titleTextStyle, TextStyle? subtitleTextStyle})
-
A highly customizable empty state widget for displaying "no content" scenarios.
const
Properties
- customWidget → Widget?
-
A custom widget to display instead of the default content.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hideSubTitle → bool
-
Whether to hide the subtitle text.
final
- hideTitle → bool
-
Whether to hide the title text.
final
- image → String?
-
The path to the image asset to display in the empty state.
final
- imageWidget → Widget?
-
A custom widget to display in place of the default image.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- packageImage → String?
-
The package name if the image is from a package.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- subtitle → String?
-
The subtitle text to display in the empty state.
final
- subtitleTextStyle → TextStyle?
-
The text style to apply to the subtitle text.
final
- title → String?
-
The title text to display in the empty state.
final
- titleTextStyle → TextStyle?
-
The text style to apply to the title text.
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