showWithStream method

ModProgressController showWithStream({
  1. required Stream<ProgressUpdate> stream,
  2. String? id,
  3. ModProgressConfig config = const ModProgressConfig(),
  4. String? title,
  5. String? subtitle,
  6. VoidCallback? onComplete,
  7. void onError(
    1. String error
    )?,
  8. VoidCallback? onClose,
  9. bool autoCloseOnComplete = false,
  10. Duration? autoCloseDelay,
})

Shows a progress overlay that listens to a stream for updates. Useful for gRPC streaming or other async progress sources.

Implementation

ModProgressController showWithStream({
  required Stream<ProgressUpdate> stream,
  String? id,
  ModProgressConfig config = const ModProgressConfig(),
  String? title,
  String? subtitle,
  VoidCallback? onComplete,
  void Function(String error)? onError,
  VoidCallback? onClose,
  bool autoCloseOnComplete = false,
  Duration? autoCloseDelay,
}) {
  // Generate ID first if not provided
  final progressId = id ?? 'progress_$_idCounter';

  final controller = show(
    id: progressId,
    config: config,
    title: title,
    subtitle: subtitle,
    onComplete: () {
      onComplete?.call();
      if (autoCloseOnComplete) {
        if (autoCloseDelay != null) {
          Future.delayed(autoCloseDelay, () {
            close(progressId);
          });
        } else {
          close(progressId);
        }
      }
    },
    onError: onError,
    onClose: onClose,
  );

  controller.connectToStream(stream);

  return controller;
}