ApiService class

A service class responsible for handling API requests.

This class provides methods to interact with a remote server, making HTTP requests and processing responses.

Example usage:

final apiService = ApiService();
final data = await apiService.fetchData();

Note: Ensure that you have proper error handling and network connectivity checks when using this service.

Constructors

ApiService({required String baseUrl, Map<String, String> defaultHeaders = const {}})

Properties

baseUrl String
A service class to handle API requests.
final
defaultHeaders Map<String, String>
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

delete(String endpoint, {Map<String, String>? headers, Map<String, dynamic>? queryParameters}) Future<Response>
Sends a DELETE request to the specified endpoint.
get(String endpoint, {Map<String, String>? headers, Map<String, dynamic>? queryParameters}) Future<Response>
Sends a GET request to the specified endpoint.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
post(String endpoint, {Map<String, String>? headers, dynamic body, Map<String, dynamic>? queryParameters}) Future<Response>
Sends a POST request to the specified endpoint.
put(String endpoint, {Map<String, String>? headers, dynamic body, Map<String, dynamic>? queryParameters}) Future<Response>
Sends a PUT request to the specified endpoint.
toString() String
A string representation of this object.
inherited

Operators

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