customJsonDecode<T> static method

dynamic customJsonDecode<T>(
  1. Response response
)

Implementation

static dynamic customJsonDecode<T>(http.Response response) {
  if (response == null) return null;

  try {
    if (T == String) {
      return response.body;
    } else if (T == List<int>) {
      return response.bodyBytes;
    } else {
      return jsonDecode(utf8.decode(response.bodyBytes));
    }
  } catch (_) {
    return response.body;
  }
}