setWiFiAPEnabled static method

Future<bool> setWiFiAPEnabled(
  1. bool state
)

Enable or Disable WiFi

Wifi API changes for Android SDK >= 29, restricts certain behaviour:

  • Uses startLocalOnlyHotspot API to enable or disable WiFi AP.
  • This can only be used to communicate between co-located devices connected to the created WiFi Hotspot
  • The network created by this method will not have Internet access

Implementation

static Future<bool> setWiFiAPEnabled(bool state) async {
  final Map<String, bool> htArguments = Map();
  htArguments["state"] = state;
  bool? bResult;
  try {
    bResult = await _channel.invokeMethod('setWiFiAPEnabled', htArguments);
  } on MissingPluginException catch (e) {
    print("MissingPluginException : ${e.toString()}");
  }
  return bResult ?? false;
}