Alguém pode me ajudar essa linha de código no meu contacs_list.dart está dando erro e não sei como resolver.
import 'package:flutter/material.dart';
import 'contact_form.dart';
import 'package:bytebank/models/contact.dart';
class ContactsList extends StatelessWidget {
final List<Contact> contacts = List();
@override
Widget build(BuildContext context) {
contacts.add(Contact('Gabriel', 1000));
contacts.add(Contact('Amanda', 2000));
return Scaffold(
appBar:
AppBar(title: Text('Contacts'), backgroundColor: Colors.green[900]),
body: ListView.builder(
itemBuilder: (context, index) {
final Contact contact = contacts[index];
return _ContactItem(contact);
},
itemCount: contacts.length,
),
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.of(context)
.push(
MaterialPageRoute(
builder: (context) => ContactForm(),
),
)
.then((newContact) => debugPrint(newContact.toString()));
},
child: Icon(Icons.add),
),
);
}
}
class _ContactItem extends StatelessWidget {
final Contact contact;
_ContactItem(this.contact);
@override
Widget build(BuildContext context) {
return Card(
child: ListTile(
title: Text(
contact.name,
style: TextStyle(fontSize: 24.0),
),
subtitle: Text(
contact.accountNumber.toString(),
style: TextStyle(fontSize: 16.0),
),
),
);
}
}