LoadingDialog class

A loading dialog widget that displays an animated loading indicator.

This widget provides a visual feedback mechanism to indicate that an operation is in progress. It uses Lottie animations for smooth, engaging loading animations that enhance the user experience.

Features

  • Animated Loading: Uses Lottie animations for smooth loading indicators
  • Consistent Design: Follows SDK design patterns and styling
  • Automatic Logging: Logs when the dialog is displayed for debugging
  • Lightweight: Minimal resource usage during loading states
  • Customizable Size: Configurable dimensions for different use cases

Usage Example

// Show loading dialog
showDialog(
  context: context,
  barrierDismissible: false,
  builder: (context) => const LoadingDialog(),
);

// Hide loading dialog
Navigator.of(context).pop();

// Or use with async operations
Future<void> processPayment() async {
  showDialog(
    context: context,
    barrierDismissible: false,
    builder: (context) => const LoadingDialog(),
  );

  try {
    await paymentService.processPayment();
  } finally {
    Navigator.of(context).pop(); // Hide loading dialog
  }
}

Animation Details

The loading animation is loaded from the SDK's assets:

  • Asset Path: lib/assets/json/lottiefiles/app_loader.json
  • Package: amwal_pay_sdk
  • Format: Lottie JSON animation file
  • Style: Consistent with SDK branding and design

Best Practices

When using this loading dialog:

  • Set barrierDismissible: false to prevent accidental dismissal
  • Always hide the dialog when the operation completes
  • Use try-finally blocks to ensure dialog is hidden even on errors
  • Consider the loading duration to avoid showing very brief loading states

Accessibility

The loading dialog provides visual feedback but consider:

  • Adding screen reader announcements for longer operations
  • Providing progress indicators for operations with known duration
  • Including cancel options for operations that can be interrupted
Inheritance

Constructors

LoadingDialog.new({Key? key})
Creates a new LoadingDialog instance.
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
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