scanWifiNetworks method
Implementation
@override
Future<List<EspWifiNetwork>> scanWifiNetworks({required String provisionProof}) async {
try {
final result = await methodChannel.invokeMethod<List>('scanWifiNetworks', {
'provision_proof': provisionProof,
});
if (result != null) {
if (result.isEmpty) {
throw PlatformException(code: 'NO_DATA', message: 'No available network');
}
return result.map<EspWifiNetwork>((e) {
final data = Map<String, dynamic>.from(e);
return EspWifiNetwork.fromJson(data);
}).toList();
} else {
throw PlatformException(code: 'NO_DATA', message: 'Opps, Something went wrong.');
}
} on PlatformException catch (e) {
throw _onPlatformException(e);
} catch (e) {
rethrow;
}
}