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');
final handler = onError;
if (handler != null) {
handler(error, stackTrace);
} else {
FlutterError.reportError(
FlutterErrorDetails(exception: error, stack: stackTrace),
);
}
},
zoneSpecification: capturePrint
? ZoneSpecification(
print: (self, parent, zone, line) {
recordDebugLog(line, source: 'print');
parent.print(zone, line);
},
)
: null,
);
return result as T;
}