forceWifiUsage static method

Future<bool> forceWifiUsage(
  1. bool useWifi
)

Route network traffic via WiFi network.

Method to force wifi usage if the user needs to send requests via wifi if it does not have internet connection. Useful for IoT applications, when the app needs to communicate and send requests to a device that have no internet connection via wifi.

Receives a boolean to enable forceWifiUsage if true, and disable if false.

Is important to enable only when communicating with the device via wifi and remember to disable it when disconnecting from device.

Implementation

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