run method
Implementation
Future<bool> run(
BuildContext context, {
IFastErrorReporter? errorReporter,
}) {
debugPrint('Job started: $debugLabel');
final completer = Completer<bool>();
var operationAsync = initialize(context, errorReporter: errorReporter);
if (!requestUserInteraction) {
operationAsync = operationAsync.timeout(timeLimit);
} else {
// Wait for the next frame to ensure that
// the next job can request a user interaction.
operationAsync = operationAsync.then((value) {
final userInteractionCompleter = Completer<void>();
WidgetsBinding.instance.scheduleFrameCallback((_) {
userInteractionCompleter.complete();
});
return userInteractionCompleter.future;
});
}
final blocInitializationOperation = CancelableOperation.fromFuture(
operationAsync,
);
operationAsync.catchError((dynamic error, StackTrace? stackTrace) {
debugPrint('Job failed: $debugLabel');
blocInitializationOperation.cancel();
completer.completeError(_transformError(error, stackTrace));
}).whenComplete(() {
if (!completer.isCompleted) {
debugPrint('Job completed: $debugLabel');
completer.complete(true);
}
});
return completer.future;
}