diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/main.dart | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/lib/main.dart b/lib/main.dart index a725658..6bc8055 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -10,11 +10,56 @@ class MainApp extends StatelessWidget { @override Widget build(BuildContext context) { return const MaterialApp( - home: Scaffold( - body: Center( - child: Text('Hello World!'), - ), + home: MainPage(), + ); + } +} + +class Contact { + final String address; + final bool isOpen; + + const Contact({required this.address, required this.isOpen}); +} + +class MainPage extends StatelessWidget { + const MainPage({super.key}); + + final List<Contact> contacts = const [ + Contact(address: "Living Room Window", isOpen: false), + Contact(address: "Front Door", isOpen: true), + Contact(address: "Back Door", isOpen: false), + Contact(address: "Garage Window", isOpen: true), + ]; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text("Contacts")), + body: ListView.builder( + itemCount: contacts.length, + itemBuilder: (context, index) { + final contact = contacts[index]; + return ContactTile(contact: contact); + }, + ), + ); + } +} + +class ContactTile extends StatelessWidget { + final Contact contact; + + const ContactTile({super.key, required this.contact}); + + @override + Widget build(BuildContext context) { + return ListTile( + leading: Icon( + contact.isOpen ? Icons.meeting_room : Icons.door_front_door, + color: contact.isOpen ? Colors.red : Colors.green, ), + title: Text(contact.address), ); } } |
