showLoader method

void showLoader(
  1. BuildContext context
)

Shows a loading dialog over the current screen.

This method displays the SDK's standard loading dialog to indicate that an operation is in progress. The dialog is presented as a route, ensuring proper navigation handling.

Parameters:

  • context - The build context for navigation and theming

Dialog Behavior

  • Modal Presentation: Dialog blocks interaction with the background
  • Route Management: Uses Navigator.push for proper navigation
  • Context Preservation: Maintains the provided context for dismissal
  • Automatic Logging: Logs when the dialog is shown

Usage

// Show loading before starting operation
showLoader(context);

try {
  await performOperation();
} finally {
  dismissDialog(context);
}

The loading dialog is presented using DialogRoute which:

  • Creates a proper navigation route
  • Handles back button behavior
  • Manages dialog lifecycle
  • Integrates with navigation stack

Error Handling

Always ensure the dialog is dismissed by using try-finally blocks or similar error handling patterns to prevent stuck loading states.

Implementation

void showLoader(BuildContext context) {
  Navigator.of(context).push(
    DialogRoute(context: context, builder: (_) => const LoadingDialog()),
  );
}