waitUntilNotPaused method

Future<void> waitUntilNotPaused()

Implementation

Future<void> waitUntilNotPaused() {
  final notPausedCompleter = Completer<bool>();
  final isPaused = isMainIsolatePaused;

  if (isPaused) {
    final mainIsolate = isolateManager.mainIsolateState;
    mainIsolate?.isPaused.addListener(() {
      final isPausedNow = isMainIsolatePaused;
      if (!isPausedNow) {
        notPausedCompleter.complete(true);
      }
    });
  } else {
    notPausedCompleter.complete(true);
  }

  return notPausedCompleter.future;
}