api_service_interceptor 0.0.2 api_service_interceptor: ^0.0.2 copied to clipboard
A Flutter package for API request with Api Service interceptor
api_service_interceptor #
A Flutter package that will help for fetching and passing data to the server.
API Service Interceptor #
How ApiServiceInterceptor Works #
Installation #
Add dependency for package on your pubspec.yaml:
dependencies:
api_service_interceptor: latest
or
flutter pub add api_service_interceptor
Usage #
final ApiServiceInterceptor apiServiceInterceptor;
Future<ApiResponseModel> loginUser(
{required String email, required String password}) async {
String url = "-------- use your api url ---------";
Map<String, String> bodyParams = {
"email": email,
"password": password
};
Map<String, String> headers = {'Content-Type': 'application/json'};
ApiResponseModel responseModel = await apiServiceInterceptor.requestToServer(
requestUrl: url,
requestMethod: ApiRequestMethod.postMethod,
bodyParams: jsonEncode(bodyParams),
headers: headers
);
return responseModel;
}
Additional Information #
This package is built on "http", "http_parser" and "shared_preferences". When we use "api_service_interceptor" package than we also use "shared_preferences" package.