Erro na classe Transaction
Error: The class 'Transaction' is abstract and can't be instantiated. final Transaction transaction = Transaction(
import 'dart:convert';
import 'package:bytebank2/models/contact.dart';
import 'package:http/http.dart';
import 'package:http_interceptor/http_interceptor.dart';
import 'package:sqflite/sqflite.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;
}