testing library

Test doubles for consumers of this package.

Import this in your own tests to get a working FakeApiServices without writing mocktail boilerplate against the ApiServices interface:

import 'package:baaba_api_handler/testing.dart';

Nothing here is imported by the package's production code, so it adds no weight to your app.

Classes

APICacheDBModel
ApiCacheHelper
A class responsible for managing caching of API data.
ApiConfig
Everything ApiServices needs, in one object.
ApiLogOptions
Controls what the console logger prints for each request.
ApiObserver
A single place to watch every request the package makes — for crash reporting, analytics, or a debug overlay.
ApiServices
A typed HTTP client wrapping Dio. All methods return Either<Failure, Response> — use .fold(onLeft, onRight) to handle errors and successes without exceptions.
AuthConfig
Token-based authentication settings for ApiServices.
Base64LogTrimmer
Collapses base64 blobs out of the logger's output.
CancelToken
Controls cancellation of Dio's requests.
Either<L, R>
Represents a value of one of two possible types, Left or Right.
FakeApiServices
An in-memory ApiServices for tests, so you can exercise a repository or controller without mocking Dio or standing up a server.
FormData
A class to create readable "multipart/form-data" streams. It can be used to submit forms and file uploads to http server.
Left<L, R>
MultipartFile
An upload content that is a part of MultipartRequest. This doesn't need to correspond to a physical file.
RecordedCall
One call made against a FakeApiServices, captured for assertions.
RequestOptions
The internal request option class that is the eventual result after BaseOptions and Options are composed.
Response<T>
The Response class contains the payload (could be transformed) that respond from the request, and other information of the response.
RetryPolicy
Controls how transient failures are retried by NetworkRetryInterceptor.
UploadFile
One file in a multipart upload.

Enums

CachePolicy
How a GET request should interact with the local response cache.
ErrorSource
HttpMethod
ResponseCode

Extensions

CachedResponse on Response

Functions

listParser<T>(T fromJson(Map<String, dynamic> json), {String? key}) List<T> Function(dynamic data)
Turns a single-object parser into one that reads a JSON array, for the common list endpoint.

Exceptions / Errors

Failure
Represents a failure from ApiServices, carrying the error type, HTTP/internal code, and a human-readable message.