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 {
|
}) async {
|
||||||
try {
|
try {
|
||||||
final response = await _dio.get(path, queryParameters: queryParameters);
|
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) {
|
} on DioException catch (e) {
|
||||||
throw _handleError(e);
|
throw _handleError(e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user