track<T> method
Implementation
@override
T track<T>(T Function() action) {
if (isStarted) {
throw StateError('Can not be tracked twice');
}
T result;
_start();
try {
result = action();
} catch (_) {
_stop();
rethrow;
}
if (result is Future) {
return result.whenComplete(_stop) as T;
} else {
_stop();
return result;
}
}