From e2a1b271e2cf417cd3104e6e0679cb54993e6d8f Mon Sep 17 00:00:00 2001 From: xengineering Date: Fri, 16 Jan 2026 21:19:16 +0100 Subject: Move Scaffold up to UI class That balances the scopes of UI and ContactList better and allows to add more Widgets on the UI level. --- lib/ui.dart | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'lib') diff --git a/lib/ui.dart b/lib/ui.dart index 4a513c6..ff8c3a8 100644 --- a/lib/ui.dart +++ b/lib/ui.dart @@ -8,8 +8,11 @@ class UI extends StatelessWidget { @override Widget build(BuildContext context) { - return const MaterialApp( - home: ContactList(), + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text("Contacts")), + body: const ContactList(), + ), ); } } @@ -19,27 +22,24 @@ class ContactList extends StatelessWidget { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(title: const Text("Contacts")), - body: Consumer( - builder: (BuildContext context, AppState state, Widget? child) { - return ListView.builder( - itemCount: state.contacts.length, - itemBuilder: (BuildContext context, int index) { - MapEntry data = state.contacts.entries.elementAt(index); - String address = data.key; - bool isOpen = data.value; - return ListTile( - leading: Icon( - isOpen ? Icons.meeting_room : Icons.door_front_door, - color: isOpen ? Colors.red : Colors.green, - ), - title: Text(address), - ); - }, - ); - }, - ), + return Consumer( + builder: (BuildContext context, AppState state, Widget? child) { + return ListView.builder( + itemCount: state.contacts.length, + itemBuilder: (BuildContext context, int index) { + MapEntry data = state.contacts.entries.elementAt(index); + String address = data.key; + bool isOpen = data.value; + return ListTile( + leading: Icon( + isOpen ? Icons.meeting_room : Icons.door_front_door, + color: isOpen ? Colors.red : Colors.green, + ), + title: Text(address), + ); + }, + ); + }, ); } } -- cgit v1.2.3-70-g09d2