import 'dart:async'; import 'package:flutter/material.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/custom_loading_overlay.dart'; Future showLoading({ required Future whileFuture, required BuildContext context, required String message, String? subMessage, bool isDesktop = false, }) async { unawaited( showDialog( context: context, barrierDismissible: false, builder: (_) => WillPopScope( onWillPop: () async => false, child: Container( color: Theme.of(context) .extension()! .overlay .withOpacity(0.6), child: CustomLoadingOverlay( message: message, subMessage: subMessage, eventBus: null, ), ), ), ), ); final result = await whileFuture; // TODO: update to flutter 3.7.x to take advantage of context.mounted // if (mounted) { Navigator.of(context, rootNavigator: isDesktop).pop(); // } return result; }