From 8dc4939e2eb055e4ba1463f931c9c69284687973 Mon Sep 17 00:00:00 2001 From: uvok Date: Tue, 29 Jul 2025 14:58:50 +0200 Subject: Fix various bugs/selection clear/all scan results get previous scan resuls as well. --- lib/device_scan_select.dart | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/device_scan_select.dart') diff --git a/lib/device_scan_select.dart b/lib/device_scan_select.dart index 27b7492..7dafe2b 100644 --- a/lib/device_scan_select.dart +++ b/lib/device_scan_select.dart @@ -61,6 +61,27 @@ class _DeviceScanSelectionState extends State { ), ); } + + @override + void didUpdateWidget(covariant DeviceScanSelection oldWidget) { + super.didUpdateWidget(oldWidget); + + if (!_deviceListEqual(oldWidget.items, widget.items)) { + setState(() { + selectedResult = -1; + }); + } + } + + bool _deviceListEqual(List oldList, List newList) { + if (oldList.length != newList.length) return false; + for (int i = 0; i < oldList.length; i++) { + if (oldList[i].device.remoteId != newList[i].device.remoteId) { + return false; + } + } + return true; + } } String firstGiven(List list) { -- cgit v1.2.3