scanWifiNetworks method

  1. @override
Future<List<EspWifiNetwork>> scanWifiNetworks({
  1. required String provisionProof,
})
override

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;
  }
}