isSuccessButNoResults function Null safety

bool isSuccessButNoResults(
  1. ParseNetworkResponse apiResponse
)

Implementation

bool isSuccessButNoResults(ParseNetworkResponse apiResponse) {
  final dynamic decodedResponse = jsonDecode(apiResponse.data);
  List<dynamic>? results;
  if (decodedResponse is Map<String, dynamic>) {
    results = decodedResponse['results'];
  } else if (decodedResponse is List<dynamic>) {
    results = decodedResponse;
  }

  if (results == null) {
    return false;
  }

  return results.isEmpty;
}