meu código esta igual ao dá aula mas não funciona.
class TransactionsList extends StatefulWidget {
const TransactionsList({Key? key}) : super(key: key);
@override
State<TransactionsList> createState() => _TransactionsListState();
}
class _TransactionsListState extends State<TransactionsList> {
final TransactionWebclient _webclient = TransactionWebclient();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Transactions'),
),
body: FutureBuilder<List<Transaction>>(
future: _webclient.findAll(),
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
break;
case ConnectionState.waiting:
return Progress();
case ConnectionState.active:
break;
case ConnectionState.done:
if (snapshot.hasData) {
final List<Transaction>? transactions = snapshot.data;
if (transactions!.isNotEmpty) {
return ListView.builder(
itemBuilder: (context, index) {
final Transaction transaction = transactions[index];
return Card(
child: ListTile(
leading: const Icon(Icons.monetization_on),
title: Text(
transaction.value.toString(),
style: const TextStyle(
fontSize: 24.0,
fontWeight: FontWeight.bold,
),
),
subtitle: Text(
transaction.contact.accountNumber.toString(),
style: const TextStyle(
fontSize: 16.0,
),
),
),
);
},
itemCount: transactions.length,
);
}
}
return CenteredMessage(
'No transactions found',
icon: Icons.warning,
);
}
return CenteredMessage(
'Unknown error',
icon: Icons.warning,
);
},
),
);
}
}