DioClient class

A reusable HTTP client class using Dio for making API requests.

This class provides common HTTP methods (GET, POST, PATCH, etc.) and handles connectivity checks, error management, and optional interceptor support.

Constructors

DioClient(Dio? dio, {List<Interceptor>? interceptors, String? baseUrl, required Connectivity connectivity})
Creates a DioClient instance.

Properties

baseUrl String?
baseUrl: The base URL for all API requests. Defaults to ChapaUrl.directChargeBaseUrl.
final
connectivity → Connectivity
connectivity: An instance of Connectivity to check internet connection.
final
hashCode int
The hash code for this object.
no setterinherited
interceptors List<Interceptor>?
interceptors: List of interceptors to be added to the Dio client.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addAuthorizationInterceptor(String publicKey) Future<void>
Adds an authorization interceptor to the Dio client.
delete(String uri, {dynamic data, Map<String, dynamic>? queryParameters, Options? options, CancelToken? cancelToken}) Future
Sends a DELETE request to the specified uri.
get(String uri, {Map<String, dynamic>? queryParameters, Options? options, CancelToken? cancelToken, ProgressCallback? onReceiveProgress}) Future
Sends a GET request to the specified uri.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
patch(String uri, {dynamic data, Map<String, dynamic>? queryParameters, Options? options, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) Future
Sends a PATCH request to the specified uri.
post(String uri, {dynamic data, Map<String, dynamic>? queryParameters, Options? options, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) Future
Sends a POST request to the specified uri.
put(String uri, {dynamic data, Map<String, dynamic>? queryParameters, Options? options, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) Future
Sends a PUT request to the specified uri.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited