ApiService class
The base class to call any endpoint
Constructors
- ApiService({required String baseUrl, required String headerAuthKey, ApiServiceLogLevel logLevel = ApiServiceLogLevel.level1})
- ApiService.mock({required String baseUrl, required String headerAuthKey, required Client client, ApiServiceLogLevel logLevel = ApiServiceLogLevel.level1})
Properties
- baseUrl → String
-
The base URL to call before using any endpoint
final
-
defaultHeaders
↔ Map<
String, String> -
The default custom headers
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- headerAuthKey → String
-
The final auth key to call authenticated endpoints
final
- logLevel → ApiServiceLogLevel
-
final
- mockClient → Client?
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
apiType(
ApiType apiType) → String - It gets the correct apiType name in base of the current ApiType
-
delete(
String endpoint, String? token, Map< String, dynamic> ? deleteData, {Map<String, dynamic> extreHeaders = const {}}) → Future<Response> - Make a delete API call
-
get(
String endpoint, String? token, Map< String, String> ? queryData, {Map<String, dynamic> extreHeaders = const {}}) → Future<Response> - Make a get API call
-
head(
String endpoint, String? token, Map< String, String> ? queryData, {Map<String, dynamic> extreHeaders = const {}}) → Future<Response> - Make a get API call
-
multipartRequest(
String endpoint, File fileAsset, String fileFieldName, String? fileName, Map< String, dynamic> ? body, String? token, {ApiType apiType = ApiType.POST}) → Future<StreamedResponse> - Make an API post multipart form call
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
patch(
String endpoint, Map< String, dynamic> body, String? token, {Map<String, dynamic> extreHeaders = const {}}) → Future<Response> - Make a patch API call
-
post(
String endpoint, Map< String, dynamic> body, String? token, {Map<String, dynamic> extreHeaders = const {}}) → Future<Response> - Make an API post call
-
postList(
String endpoint, List body, String? token, {Map< String, dynamic> extreHeaders = const {}}) → Future<Response> - Make an API post call
-
put(
String endpoint, Map< String, dynamic> body, String? token, {Map<String, dynamic> extreHeaders = const {}}) → Future<Response> - Make a put API call
-
putList(
String endpoint, List body, String? token, {Map< String, dynamic> extreHeaders = const {}}) → Future<Response> - Make an API post call
-
setMockClient(
Client? mockClient) → void -
simulateApiCall(
{Duration? duration}) → Future< void> - Call this function to simulate an interval seconds to wait before get the fake data from the fake api call
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited