wifiDisconnect method

void wifiDisconnect({
  1. dynamic callback(
    1. bool isSuccess
    )?,
})

Implementation

void wifiDisconnect({Function(bool isSuccess)? callback}) {
  MethodChannel methodChannel = const MethodChannel(messageChannelID);
  Map map = {'wifiName': '', 'wifiPassword': '', 'operation': 'disconnect'};

  methodChannel.invokeListMethod("flutterCallNativeWifi", map);
  methodChannel.setMethodCallHandler((call) async {
    if (call.method == 'nativeCallFlutterWifi') {
      var message = call.arguments;

      if (message["isSuccess"] == true) {
        Fluttertoast.showToast(msg: '切换wifi成功');
        if (callback != null) {
          callback(true);
        }
      } else {
        Fluttertoast.showToast(msg: message["msg"]);
        if (callback != null) {
          callback(false);
        }
      }
    }
  });
}