runWithDiagnosticsZone<T> method
T
runWithDiagnosticsZone<
T>( - T body(), {
- void onError(
- Object error,
- StackTrace stackTrace
)?,
})
Implementation
T runWithDiagnosticsZone<T>(
T Function() body, {
void Function(Object error, StackTrace stackTrace)? onError,
}) {
T? result;
runZonedGuarded(
() {
result = body();
},
(error, stackTrace) {
recordUnhandledError(error, stackTrace, source: 'Zone');
onError?.call(error, stackTrace);
},
zoneSpecification: capturePrint
? ZoneSpecification(
print: (self, parent, zone, line) {
recordDebugLog(line, source: 'print');
parent.print(zone, line);
},
)
: null,
);
return result as T;
}