FacadeHttpRequestUsecases class
Facade aggregating all HTTP request use cases.
This class is meant to be injected into blocs/managers that need to issue HTTP calls in a centralized and testable way, without depending on the underlying RepositoryHttpRequest directly.
Example:
class BlocSomeFeature {
BlocSomeFeature(this._http);
final FacadeHttpRequestUsecases _http;
Future<void> loadData() async {
final Uri uri = Uri.parse('https://api.example.com/v1/data');
final Either<ErrorItem, ModelConfigHttpRequest> result = await _http.get(
uri,
metadata: <String, dynamic>{'feature': 'someFeature'},
);
result.fold(
(ErrorItem error) {
// Handle error in the feature bloc.
},
(ModelConfigHttpRequest config) {
// Optionally store config for retry/telemetry.
},
);
}
}
Constructors
- FacadeHttpRequestUsecases({required UsecaseHttpRequestGet get, required UsecaseHttpRequestPost post, required UsecaseHttpRequestPut put, required UsecaseHttpRequestDelete delete, required UsecaseHttpRequestRetry retry})
-
Creates a new FacadeHttpRequestUsecases grouping all HTTP use cases.
const
Properties
- delete → UsecaseHttpRequestDelete
-
Use case for DELETE operations.
final
- get → UsecaseHttpRequestGet
-
Use case for GET operations.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- post → UsecaseHttpRequestPost
-
Use case for POST operations.
final
- put → UsecaseHttpRequestPut
-
Use case for PUT operations.
final
- retry → UsecaseHttpRequestRetry
-
Use case for retrying a previous HTTP configuration.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited