wifiSetting method

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

Implementation

void wifiSetting({Function(bool isSuccess)? callback}) {
  MethodChannel methodChannel = const MethodChannel(messageChannelID);
  Map map = {
    'wifiName': model!.wifiName,
    'wifiPassword': model!.wifiPassword,
    'operation': 'connect'
  };
  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);
        }
      }
    }
  });
}