skip to Main Content

Flutter sort, map, reduce List of map

Hey so I have this this sample List data from api, and im trying to show it to fl_charts [ {"type": "expense", "amount": 250, "paymentDate": "22-02-2022"}, {"type": "income", "amount": 350, "paymentDate": "22-02-2022"}, {"type": "expense", "amount": 150, "paymentDate": "22-02-2022"}, {"type": "expense",…

VIEW QUESTION

type '(dynamic) => ProductModel' is not a subtype of type '(String, dynamic) => MapEntry<dynamic, dynamic>' of 'transform' – Flutter

Tried almost every solution. No luck :( Future<List<ProductModel>> getProducts() async { try { final response = await apiService.sendRequest.get('/product'); if (response.data != null) { print("Data == $response"); return response.data .map((e) => ProductModel.fromJson(e.toMap())) // error is thrown here .toList(); } return <ProductModel>[];…

VIEW QUESTION
Back To Top
Search