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 a CircularProgressIndicator that dynamically matches the merchant's theme color for consistent branding.

Features

  • Theme-Aware: Uses the merchant's primary color from AmwalThemeManager
  • 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

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
  }
}

Theme Integration

The loading spinner color is determined by:

  • Primary Color: Uses AmwalThemeManager.instance.primaryColor
  • Default: Falls back to purple (#7F22FF) if no custom color is set
  • Custom: Merchants can set their brand color via SDK settings

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({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