diff options
author | uvok | 2025-07-29 14:58:50 +0200 |
---|---|---|
committer | uvok | 2025-07-29 14:58:50 +0200 |
commit | 8dc4939e2eb055e4ba1463f931c9c69284687973 (patch) | |
tree | c042c5f463c27809da039fde479a3bdb15746dbc /lib/device_scan_select.dart | |
parent | 7c0f47a946939875b13250b204898911fc525827 (diff) |
Fix various bugs/selection clear/all scan results
get previous scan resuls as well.
Diffstat (limited to 'lib/device_scan_select.dart')
-rw-r--r-- | lib/device_scan_select.dart | 21 |
1 files changed, 21 insertions, 0 deletions
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<DeviceScanSelection> { ), ); } + + @override + void didUpdateWidget(covariant DeviceScanSelection oldWidget) { + super.didUpdateWidget(oldWidget); + + if (!_deviceListEqual(oldWidget.items, widget.items)) { + setState(() { + selectedResult = -1; + }); + } + } + + bool _deviceListEqual(List<ScanResult> oldList, List<ScanResult> 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<String> list) { |