From f8cf9dc0a8b7e67e4c0f7e2d40b0b4ab26a5ed0a Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 10 Jan 2026 21:37:51 +0100 Subject: Re-introduce timer-based state toggling This is now done with the refactored code organization and a strict UI / data split. --- lib/data.dart | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/data.dart b/lib/data.dart index 5cd59ec..4091bb3 100644 --- a/lib/data.dart +++ b/lib/data.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/foundation.dart'; class AppState with ChangeNotifier { @@ -7,6 +9,29 @@ class AppState with ChangeNotifier { Contact(address: "Back Door", isOpen: false), Contact(address: "Garage Window", isOpen: true), ]; + + Timer? _timer; + + AppState() { + _timer = Timer.periodic(const Duration(seconds: 1), (_) { + toggleFirstContact(); + }); + } + + void toggleFirstContact() { + if (contacts.isEmpty) { + return; + } + + contacts[0].isOpen = !contacts[0].isOpen; + notifyListeners(); + } + + @override + void dispose() { + _timer?.cancel(); + super.dispose(); + } } class Contact { -- cgit v1.2.3-70-g09d2