`
`
Olá! estou com esse erro citado acima. ainda não consegui resolver. poderia me ajudar?
curso: Web API integrando sua App Mobile
modulo: apresentando dados da web API na tela do app
atividade: Convertendo json para objeto do Dart
codigo: Future<List> findAll() async { Client client = InterceptedClient.build(interceptors: [ LoggingInterceptor(), ]);
Uri url = Uri.parse('http://192.168.0.107:8080/transactions'); Response response = await client.get(url);
final List decodeJeson = jsonDecode(response.body); final List transactions = [];
for (Map<String, dynamic> transactionJson in decodeJeson) { final Map<String, dynamic> contactJson = transactionJson['contact']; final Transaction transaction = Transaction( transactionJson['value'], Contact( 0, contactJson['name'], contactJson['accountNumber'], //contactJson['contact']['number'], ), ); transactions.add(transaction); }
print(response.body); print('decode json: ${decodeJeson}'); return transactions; }
//classe do http_interceptor class LoggingInterceptor implements InterceptorContract { @override Future interceptRequest({required RequestData data}) async { print('Request'); print('dados: ${data.toString()}'); print('url: ${data.url}'); print('cabeçalho: ${data.headers}'); print('corpo: ${data.body}'); return data; }
@override Future interceptResponse({required ResponseData data}) async { print('Response'); print('dados: ${data.toString()}'); print('status Code: ${data.statusCode}'); print('cabeçalho: ${data.headers}'); print('corpo: ${data.body}'); return data; } }