request method
Loads and returns data for a one-time request.
Unlike calling fetchData directly, manages loading, success, and failure states and automatically disposes the service when the request completes.
Errors are propagated regardless of canRethrow. Use with a fresh service in ServiceStatus.none. do not reuse it afterward.
Implementation
Future<T> request() async {
assert(
status == .none,
'Service.request() requires an unused service with ServiceStatus.none.',
);
try {
_status = .loading;
done(await fetchData());
return data;
} catch (error) {
fail(error);
rethrow;
} finally {
dispose();
}
}