I make the request as follows
final url = Uri.http(_baseUrl, 'api/ProductoTerminado/ListaProductos');
final resp =
await http.get(url, headers: {"Content-Type": "application/json"});
print(resp.body);
when printing it if it solves me and marks the next answer
[{"ot":"1 ","pedido":"1 ","posicion":1,"sociedad":"1 ","numeroCliente":"1 ","cliente":"1 ","pieza":"1 ","codigoMaterial":"1 ","producto":"1 ","cantidad":1.99,"importe":1,"fecha":"2022-01-18T00:00:00"},{"ot":"2 ","pedido":"300399 ","posicion":30,"sociedad":"M3M ","numeroCliente":"3050 ","cliente":"TUBOS DE ACERO DE MEXICO S.A. ","pieza":"2 ","codigoMaterial":"40152 ","producto":"PLACA BASE CIRCULAR 3T DE 2800 DIAMETRO ","cantidad":2.01,"importe":231406.48,"fecha":"2022-01-18T00:00:00"}]
when I try to map to my data I get an error on the following line
final Map<String, dynamic> userMap = json.decode(resp.body);
and in console mark the following
Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>'
I have already reviewed it and searched and in the line where I do the json decode it still gives the same error
resp.body
is a list like you have in theprint
. change the codeBy