Add null check in ApiClient.getList to handle cases where response.data is null, returning empty list instead of throwing cast error
This commit is contained in:
@@ -125,7 +125,9 @@ class ApiClient {
|
||||
}) async {
|
||||
try {
|
||||
final response = await _dio.get(path, queryParameters: queryParameters);
|
||||
return (response.data as List).map(fromJson).toList();
|
||||
final data = response.data;
|
||||
if (data == null) return [];
|
||||
return (data as List).map(fromJson).toList();
|
||||
} on DioException catch (e) {
|
||||
throw _handleError(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user