import 'package:bytebank2/database/app_database.dart';
import 'package:bytebank2/models/contact.dart';
import 'package:bytebank2/screens/contact_form.dart';
import 'package:flutter/material.dart';
class ContactList extends StatefulWidget {
@override
State<ContactList> createState() => _ContactListState();
}
class _ContactListState extends State<ContactList> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Contacts'),
),
body: FutureBuilder(
future: findAll(),
builder: (context, snapshot) {
return ListView.builder(
itemBuilder: (BuildContext context, int index) {
final List<Contact>? contacts = snapshot.data as List<Contact>?;
final Contact contact = contacts![index];
return _ContactItem(contact);
},
itemCount: contacts.legth, (O ERRO ESTÁ SENDO APONTADO AQUI)
);
},),
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) {
// TODO: implement build
return Card(
child: ListTile(
title: Text(
contact.name,
style: TextStyle(fontSize: 24),
),
subtitle: Text(
contact.accountNumber.toString(),
style: TextStyle(fontSize: 16),
),
),
);
}
}
Basicamente está no msm lugar que o do professor mais quando eu executo da esse erro não sei o porque.