Katipunero-
Eternal Poster
- Joined
- Mar 22, 2020
- Posts
- 790
- Reaction
- 318
- Points
- 312
Sometimes, you'll run into some linter errors like
You can fix it by temporary adding
data type of incoming request from server.
implicit_dynamic_method
.You can fix it by temporary adding
dynamic
to Response<T>
if you really don't know what will be thedata type of incoming request from server.
Code:
Future<List<Card>> fetchCustomerCards(int userID) async {
try {
final _uri = Uri.parse('/users/$userID/cards');
final response = await dioClient.get<dynamic>(
_uri.path,
);
if (response.data != null) {
final responseList = response.data! as List;
final cards = responseList
.map(
(dynamic e) => Card.fromJson(e as JsonMap),
)
.toList();
return cards;
}
return [];
} on DioError catch (e) {
print(e);
if (e.response?.statusCode == 300) {
throw CustomFailure.fromJson(e.response!.data as JsonMap);
}
throw CustomFailure.fromJson(e.response!.data as JsonMap);
} catch (e) {
print(e);
throw const CustomFailure();
}
}