track<T> method
T
track<
T>( - T action()
)
override
Implementation
@override
T track<T>(T Function() action) {
if (isStarted) {
throw StateError('Can not be tracked twice');
}
_tracking = true;
final result = runZoned(action,
zoneSpecification: asyncTimeTrackerZoneSpecification,
zoneValues: {_zoneKey: this});
if (result is Future) {
return result
// Break possible sync processing of future completion, so slice trackers can be finished
.whenComplete(() => Future.value())
.whenComplete(() => _tracking = false) as T;
} else {
_tracking = false;
return result;
}
}