handle empty data... idk why this is even an issue...
This commit is contained in:
@@ -91,12 +91,21 @@ class _DeviceSetupState extends State<DeviceSetup> {
|
|||||||
List<int> rawData = await ssidListChar.read();
|
List<int> rawData = await ssidListChar.read();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (rawData.isEmpty) {
|
||||||
|
throw Exception("No data received from device");
|
||||||
|
}
|
||||||
|
|
||||||
final val = utf8.decode(rawData);
|
final val = utf8.decode(rawData);
|
||||||
|
if (val.trim().isEmpty) {
|
||||||
|
throw Exception("Empty response from device");
|
||||||
|
}
|
||||||
|
|
||||||
final decoded = json.decode(val) as List;
|
final decoded = json.decode(val) as List;
|
||||||
networks = decoded.map((e) => e as Map<String, dynamic>).toList();
|
networks = decoded.map((e) => e as Map<String, dynamic>).toList();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if(!mounted)return;
|
if(!mounted)return;
|
||||||
ScaffoldMessenger.of(context).showSnackBar(errorSnackbar(e));
|
ScaffoldMessenger.of(context).showSnackBar(errorSnackbar(e));
|
||||||
|
networks = []; // Set to empty list on error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Acknowledge completion
|
// Acknowledge completion
|
||||||
|
|||||||
Reference in New Issue
Block a user