post<T> method

Future<T?> post<T>({
  1. required String endPointURL,
  2. Map<String, dynamic>? data,
  3. Map<String, dynamic>? header,
  4. bool addToCache = true,
})

Base HTTP post request.

By default it will store data in apiCacheStorage with endPointURL as Storage Key.

Implementation

Future<T?> post<T>({required String endPointURL, Map<String, dynamic>? data, Map<String, dynamic>? header, bool addToCache = true}) async {
  Response response = await _dio.post(endPointURL, data: data, options: Options(headers: header));
  if (response.statusCode == 200) {
    if (addToCache) _storage.write(endPointURL, response.data);
    return response.data;
  } else {
    return null;
  }
}