showMaterialDialog static method

void showMaterialDialog({
  1. Color color = Colors.grey,
})

Displays a centered circular progress indicator dialog.

Shows a simple loading dialog with a customizable color circular progress indicator. The dialog has a transparent background and no elevation, displaying only the progress indicator. Commonly used during API calls.

Parameters:

  • color: Color of the circular progress indicator (defaults to grey)

The dialog is modal and can be dismissed by calling Get.back().

Example:

// Show loading dialog
RtCommonFunction.showMaterialDialog(color: Colors.blue);

// Perform API call
await someApiCall();

// Dismiss dialog
Get.back();

See also:

Implementation

static void showMaterialDialog({Color color = Colors.grey}) {
  WidgetsBinding.instance.addPostFrameCallback((_) {
    Get.dialog(
      AlertDialog(
        backgroundColor: Colors.transparent,
        elevation: 0,
        content: Center(
          child: CircularProgressIndicator(
            valueColor: AlwaysStoppedAnimation<Color>(color),
          ),
        ),
      ),
    );
  });
}