handle empty data... idk why this is even an issue...

This commit is contained in:
2026-01-10 22:56:30 -06:00
parent 4e7e8661e5
commit 47f3169838

View File

@@ -91,12 +91,21 @@ class _DeviceSetupState extends State<DeviceSetup> {
List<int> rawData = await ssidListChar.read();
try {
if (rawData.isEmpty) {
throw Exception("No data received from device");
}
final val = utf8.decode(rawData);
if (val.trim().isEmpty) {
throw Exception("Empty response from device");
}
final decoded = json.decode(val) as List;
networks = decoded.map((e) => e as Map<String, dynamic>).toList();
} catch (e) {
if(!mounted)return;
ScaffoldMessenger.of(context).showSnackBar(errorSnackbar(e));
networks = []; // Set to empty list on error
}
// Acknowledge completion