diff options
| author | xengineering <me@xengineering.eu> | 2026-01-11 20:26:03 +0100 |
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2026-01-11 20:26:03 +0100 |
| commit | ad86cd926d5da6031930de79cbe85df7ff40df1c (patch) | |
| tree | e13de1e14ca42f31466416c3f17a2bc98f385a73 /lib/ui.dart | |
| parent | 0692db03e155054c8732da49eefba44d9c7ea549 (diff) | |
| download | sia-app-ad86cd926d5da6031930de79cbe85df7ff40df1c.tar sia-app-ad86cd926d5da6031930de79cbe85df7ff40df1c.tar.zst sia-app-ad86cd926d5da6031930de79cbe85df7ff40df1c.zip | |
Switch to Map address to state for contacts
This map should be empty in the future and updated based on the incoming
MQTT messages.
A list was not the correct data structure for that since it requires to
iterate over the whole list to find the entry with a certain address.
But this is required to update the state of an already known contact.
Diffstat (limited to 'lib/ui.dart')
| -rw-r--r-- | lib/ui.dart | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/ui.dart b/lib/ui.dart index d4618cf..4a513c6 100644 --- a/lib/ui.dart +++ b/lib/ui.dart @@ -26,13 +26,15 @@ class ContactList extends StatelessWidget { return ListView.builder( itemCount: state.contacts.length, itemBuilder: (BuildContext context, int index) { - final Contact contact = state.contacts[index]; + MapEntry<String, bool> data = state.contacts.entries.elementAt(index); + String address = data.key; + bool isOpen = data.value; return ListTile( leading: Icon( - contact.isOpen ? Icons.meeting_room : Icons.door_front_door, - color: contact.isOpen ? Colors.red : Colors.green, + isOpen ? Icons.meeting_room : Icons.door_front_door, + color: isOpen ? Colors.red : Colors.green, ), - title: Text(contact.address), + title: Text(address), ); }, ); |
