Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Erro transaction.add(transaction);

Erro The method 'add' isn't defined for the type 'Transaction' na linha transaction.add(transaction);

import 'dart:convert';
import 'package:bytebank2/models/contact.dart';
import 'package:bytebank2/models/transaction.dart';
import 'package:http/http.dart';
import 'package:http_interceptor/http_interceptor.dart';

class LoggingInterceptor implements InterceptorContract {
  @override
  Future<RequestData> interceptRequest({required RequestData data}) async {
    print('Request');
    print('url: ${data.url}');
    print('headers: ${data.headers}');
    print('body: ${data.body}');
    return data;
  }

  @override
  Future<ResponseData> interceptResponse({required ResponseData data}) async {
    print('Response');
    print('status quode: ${data.statusCode}');
    print('headers: ${data.headers}');
    print('body: ${data.body}');
    return data;
  }

}

Future<List<Transaction>> findAll() async {
  final Client client = InterceptedClient.build(
     interceptors: [LoggingInterceptor()],
  );

  final Response response =
    await client.get(Uri.parse('http://192.168.0.6:8080/transactions'));

  final List<dynamic> decodedJson = jsonDecode(response.body);
  final List<Transaction> transactions = [];

  for (Map<String, dynamic> transactionJson in decodedJson){
    final Map<String, dynamic> contactJson = transactionJson['contact'];

    final Transaction transaction = Transaction(
        transactionJson['value'],
        Contact(
          0,
          contactJson['name'],
          contactJson['accountNumber'],
      ),
    );
    transaction.add(transaction);
  }
  return transactions;
}
1 resposta
solução!

Correta instrução é com "transactions":

transactions.add(transaction);