dlgLoading<T> method

Future<T?> dlgLoading<T>({
  1. required String message,
  2. required Future<void> task(),
  3. double? height,
  4. String? title,
  5. double? width,
})

Provides the ability to run an async task and present a wait dialog. It is important you call CodeMeltedUI.dlgClose to properly clear the dialog and return any value expected.

Implementation

Future<T?> dlgLoading<T>({
  required String message,
  required Future<void> Function() task,
  double? height,
  String? title,
  double? width,
}) async {
  Future.delayed(Duration.zero, task);
  return dlgCustom<T>(
    content: Row(
      children: [
        const SizedBox(width: 5.0),
        SizedBox(
          height: 25.0,
          width: 25.0,
          child: CircularProgressIndicator(
            color: _getTheme().contentColor,
          ),
        ),
        const SizedBox(width: 5.0),
        Text(
          message,
          softWrap: true,
          overflow: TextOverflow.ellipsis,
          style: TextStyle(color: _getTheme().contentColor),
        ),
      ],
    ),
    height: height,
    title: title ?? "Please Wait",
    width: width,
  );
}