wifiSetting method

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

Implementation

void wifiSetting({Function(bool isSuccess)? callback}) {
  BasicMessageChannel messageChannel = const BasicMessageChannel(
      messageForWifiChannelID, StandardMessageCodec());
  Map map = {
    'wifiName': model!.wifiName,
    'wifiPassword': model!.wifiPassword,
    'operation': 'connect'
  };
  messageChannel.send(map);
  messageChannel.setMessageHandler((message) async {
    if (message["isSuccess"] == true) {
      Fluttertoast.showToast(msg: '切换wifi成功');
      if (callback != null) {
        callback(true);
      }
    } else {
      Fluttertoast.showToast(msg: message["msg"]);
      if (callback != null) {
        callback(false);
      }
    }
  });
}