showProgressDialogWidget function

ProgressFuture showProgressDialogWidget (
  1. Widget widget,
  2. {BuildContext context,
  3. VoidCallback onDismiss,
  4. TextDirection textDirection,
  5. bool handleTouch}
)

show widget with progress dialog

Implementation

ProgressFuture showProgressDialogWidget(
  Widget widget, {
  BuildContext context,
  VoidCallback onDismiss,
  TextDirection textDirection,
  bool handleTouch,
}) {
  context ??= _contextMap.values.first;
  OverlayEntry entry;
  ProgressFuture future;

  var direction = textDirection ??
      _ProgressTheme.of(context).textDirection ??
      TextDirection.ltr;

  GlobalKey<_ProgressContainerState> key = GlobalKey();

  widget = Align(
    child: widget,
    alignment: Alignment.center,
  );

  entry = OverlayEntry(builder: (ctx) {
    return IgnorePointer(
      ignoring: true,
      child: _ProgressContainer(
        key: key,
        child: Directionality(textDirection: direction, child: widget),
      ),
    );
  });

  // only one progress dialog at a time is showing
  ProgressManager().dismissAll();

  future = ProgressFuture._(entry, onDismiss, key);

  Overlay.of(context).insert(entry);
  ProgressManager().addFuture(future);
  return future;
}