validateData<ResultType, Item> method
Returns the body to cache, or null when it should not be cached.
Guards against storing an empty collection, which would otherwise be served back as a valid (but useless) cache hit.
Implementation
ResultType? validateData<ResultType, Item>(
ApiResponse<ResultType, Item> response,
) {
final data = response.body;
// Checked on the value: `ResultType is Iterable<Item>` compares a type
// argument against a type and is always false, so it never guarded
// anything.
if (data is Iterable && data.isEmpty) return null;
return data;
}