get abstract method
Sends a GET request to endpoint.
Use for fetching resources that don't require a request body. Query
parameters go in params.
Returns Right(Response) on success, Left(Failure) on any error
(network, timeout, 4xx/5xx, no internet).
Example:
final result = await _api.get(
endpoint: '/users',
params: {'page': 1, 'limit': 20},
);
result.fold(
(failure) => emit(ErrorState(failure.message)),
(response) => emit(LoadedState(UserListModel.fromJson(response.data))),
);
Implementation
Future<Either<Failure, Response>> get({
required String endpoint,
Object? data,
Map<String, dynamic>? params,
Duration? receiveTimeout,
Duration? sendTimeout,
Map<String, String>? headers,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
CancelToken? cancelToken,
bool showLoader = true,
});