runWithOutputAsync<T> method
Future<T>
runWithOutputAsync<T>(
- FutureOr<
T> body(- RenderOutput out
- bool clearOnEnd = false,
Runs body with a RenderOutput, ensuring cleanup after awaited work.
Implementation
Future<T> runWithOutputAsync<T>(
FutureOr<T> Function(RenderOutput out) body, {
bool clearOnEnd = false,
}) {
final out = RenderOutput();
start();
return Future.sync(() => body(out)).whenComplete(() {
end();
if (clearOnEnd) out.clear();
});
}