RetryWidget class
RetryWidget Class Documentation
The RetryWidget
class is a Flutter widget that provides a user-friendly way to display an error message along with a retry button. It is commonly used to prompt users to retry an action that previously failed, such as network requests or form submissions.
Constructors:
RetryWidget({Key? key, Function()? onPressed, String? message, String? label})
: Constructs an instance ofRetryWidget
with optional parameters.
Properties:
-
onPressed
: A callback function that is executed when the retry button is pressed. It typically triggers the action that needs to be retried. -
message
: An optional string message that describes the error or reason for the retry. -
label
: An optional label for the retry button. The default label is "Try Again."
Widgets:
The RetryWidget
consists of the following widgets:
-
A text widget displaying the error message in red text if provided.
-
A material button with a red background for retrying the action. The button label defaults to "Try Again."
Usage Example:
RetryWidget(
onPressed: () {
// Retry the action here.
},
message: 'Failed to load data. Please try again.',
)
Parameters:
-
onPressed
: A function that will be called when the retry button is pressed. It is typically used to trigger the action that needs to be retried. -
message
: An optional string message that describes the error or reason for the retry. If provided, it will be displayed in red text above the retry button. -
label
: An optional string label for the retry button. If not provided, the default label "Try Again" will be used.
Use Case:
Use the RetryWidget
in your UI when you want to give users the option to retry an action that has failed, such as reloading data after a network error or resubmitting a form after validation errors.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- RetryWidget
Constructors
- RetryWidget.new({Key? key, dynamic onPressed()?, String? message, String? label})
-
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
- label → String?
-
final
- message → String?
-
final
- onPressed → dynamic Function()?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
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