getNetworks method

Future<List<WiFiNetwork>> getNetworks()

Returns a list of WiFiNetwork available networks on the remote device

Implementation

Future<List<WiFiNetwork>> getNetworks() async {
  await scanNetwork();
  final command = 0;
  final data = await _write('{"c":$command}', _wifiRequest, _wifiResponse, command: command);
  final networks = <WiFiNetwork>[];
  data.forEach((network) => networks.add(WiFiNetwork(
        ssid: network['e'],
        signalStrength: network['s'],
        macAddress: network['m'],
        isOpen: network['p'] == 0,
      )));
  return networks;
}