init method

Future<void> init(
  1. QweatherConfig config
)
inherited

初始化

Implementation

Future<void> init(QweatherConfig config) async {
  String publicId = '', key = '';
  if (Platform.isAndroid) {
    publicId = config.publicIdForAndroid;
    key = config.keyForAndroid;
  } else if (Platform.isIOS) {
    publicId = config.publicIdForIos;
    key = config.keyForIos;
  }
  if (publicId.isEmpty || key.isEmpty)
    return print("和风天气:当前平台的 publicId 或 key 为空");
  final Map<String, dynamic> param = {
    "publicId": publicId,
    "key": key,
    "biz": config.biz,
    "debug": config.debug
  };
  final ok = await _methodChannel.invokeMethod(MethodConstants.Init, param);
  if (config.debug) print("和风天气:初始化结果: $ok");
}