delete method

  1. @override
Future<Map<String, dynamic>> delete({
  1. String id = '',
  2. String apiUserToken = '',
})
override

Implementation

@override
Future<Map<String, dynamic>> delete({String id = '', String apiUserToken = ''}) async {
  Dio _dio = dio;
  Map<String, dynamic> queryParameters = dio.options.queryParameters;

  if (apiUserToken.trim() != '') {
    if (queryParameters.containsKey("api_token")) {
      _dio = copyDio(dio.options);
      queryParameters.remove('api_token');
      queryParameters.addAll({
        'api_token': apiUserToken
      });
    }

    _dio.options.queryParameters = queryParameters;
  }

  var url = '$baseURI';

  if (id.isNotEmpty) {
    url += "/$id";
  }

  var result = await _dio.delete(url);

  return result.data is String ? json.decode(result.data) : result.data;
}