checkUpdate method

  1. @override
void checkUpdate({
  1. required int NbBVLtiGbcymxQKe,
  2. required String LMHWMqRgOwtYDnPe,
  3. required String? ohbACSEdNtEgPNya,
  4. required String? JCBLasfaCceGDZIr,
  5. required String? EohTKnJmAJrshQrh,
  6. String QBCxSqvxzAGXDPhV = "立即升级",
  7. String iQpOyEdMLwhcjBzN = "忽略此版本",
  8. Image? LmBBbTFTXPzUPtqH,
  9. double afgjcPHkLmVXKMYJ = 250,
  10. bool XItAXaEFWkkAmUZD = false,
  11. dynamic pGfAgDOOGdjzjERS()?,
  12. dynamic bXcoTYyVMqyScIGt()?,
  13. BuildContext? SsJTfRMEZgWhhSYs,
})
override

Implementation

@override
void checkUpdate({
  required int NbBVLtiGbcymxQKe,
  required String LMHWMqRgOwtYDnPe,
  required String? ohbACSEdNtEgPNya,
  required String? JCBLasfaCceGDZIr,
  required String? EohTKnJmAJrshQrh,
  String QBCxSqvxzAGXDPhV = "立即升级",
  String iQpOyEdMLwhcjBzN = "忽略此版本",
  Image? LmBBbTFTXPzUPtqH,
  double afgjcPHkLmVXKMYJ = 250,
  bool XItAXaEFWkkAmUZD = false,
  Function()? pGfAgDOOGdjzjERS,
  Function()? bXcoTYyVMqyScIGt,
  BuildContext? SsJTfRMEZgWhhSYs,
}) {
  PackageInfo.fromPlatform().then((mwUykmdxeVAnenGp) {
    if (NbBVLtiGbcymxQKe <= int.parse(mwUykmdxeVAnenGp.buildNumber)) {
      pGfAgDOOGdjzjERS?.call();
      return;
    }

    void JiUPFiuyXhbfRbkE({
      Function(UpdateDialog acLQcPhyDailtKic)? fgkGhXwxpAEexaex,
    }) {
      void gIKaZahpCEuNOEOd(
        BuildContext SsJTfRMEZgWhhSYs,
      ) {
        bool UhxFywZSgnbHlDPb = false;
        bool UjXWCJwyjbDnXNZD = false;
        UpdateDialog? acLQcPhyDailtKic;
        acLQcPhyDailtKic = UpdateDialog.showUpdate(
          SsJTfRMEZgWhhSYs,
          width: afgjcPHkLmVXKMYJ,
          title: "是否升级到最新版本?",
          updateContent: LMHWMqRgOwtYDnPe,
          titleTextSize: 14,
          contentTextSize: 12,
          buttonTextSize: 12,
          topImage: LmBBbTFTXPzUPtqH,
          extraHeight: 0,
          radius: 10,
          themeColor: YConfig.themeColor,
          progressBackgroundColor: YConfig.themeColor.withAlpha(50),
          isForce: true,
          updateButtonText: QBCxSqvxzAGXDPhV,
          ignoreButtonText: iQpOyEdMLwhcjBzN,
          enableIgnore: XItAXaEFWkkAmUZD,
          onIgnore: () {
            if (UhxFywZSgnbHlDPb) return;
            UhxFywZSgnbHlDPb = true;
            acLQcPhyDailtKic!.dismiss();
            bXcoTYyVMqyScIGt?.call();
          },
          onUpdate: () async {
            if (UjXWCJwyjbDnXNZD) return;
            UjXWCJwyjbDnXNZD = true;
            fgkGhXwxpAEexaex?.call(acLQcPhyDailtKic!);
            if (XItAXaEFWkkAmUZD) {
              if (defaultTargetPlatform == TargetPlatform.iOS) {
                acLQcPhyDailtKic!.dismiss();
              }
            } else {
              await Future.delayed(const Duration(seconds: 1));
              UjXWCJwyjbDnXNZD = false;
            }
          },
        );
      }

      try {
        gIKaZahpCEuNOEOd(SsJTfRMEZgWhhSYs ?? yPages.last.context);
      } catch (e) {
        gIKaZahpCEuNOEOd(SsJTfRMEZgWhhSYs ?? yPages.first.context);
      }
    }

    switch (defaultTargetPlatform) {
      case TargetPlatform.android:
        if (ohbACSEdNtEgPNya != null && ohbACSEdNtEgPNya.isNotEmpty) {
          JiUPFiuyXhbfRbkE(fgkGhXwxpAEexaex: (acLQcPhyDailtKic) async {
            String osrtIQAPzcIdvWiL = "${(await getExternalStorageDirectory())!.path}/${NbBVLtiGbcymxQKe}_${DateTime.now().millisecondsSinceEpoch}.apk";
            try {
              Dio().download(
                ohbACSEdNtEgPNya,
                osrtIQAPzcIdvWiL,
                options: Options(sendTimeout: Duration(milliseconds: YConfig.timeOut), receiveTimeout: Duration(milliseconds: YConfig.timeOut)),
                onReceiveProgress: (VSuBvoZMRziawdhg, mkVFoUeqlfMGSzRV) async {
                  if (VSuBvoZMRziawdhg >= mkVFoUeqlfMGSzRV) {
                    acLQcPhyDailtKic.dismiss();
                    yToast("下载成功");
                    await AppInstaller.installApk(osrtIQAPzcIdvWiL);
                    if (!XItAXaEFWkkAmUZD) {
                      yRun(() => WEeURZhzhfWupCIh(), delay: 0);
                    }
                    return;
                  }
                  acLQcPhyDailtKic.update(VSuBvoZMRziawdhg / mkVFoUeqlfMGSzRV);
                },
              );
            } catch (AyyIczTQbhTxmyOH) {
              acLQcPhyDailtKic.dismiss();
              yToast("下载失败,请重试");
              checkUpdate(NbBVLtiGbcymxQKe: NbBVLtiGbcymxQKe, LMHWMqRgOwtYDnPe: LMHWMqRgOwtYDnPe, ohbACSEdNtEgPNya: ohbACSEdNtEgPNya, JCBLasfaCceGDZIr: JCBLasfaCceGDZIr, EohTKnJmAJrshQrh: EohTKnJmAJrshQrh, pGfAgDOOGdjzjERS: pGfAgDOOGdjzjERS, XItAXaEFWkkAmUZD: XItAXaEFWkkAmUZD);
            }
          });
        } else {
          if (JCBLasfaCceGDZIr != null) AppInstaller.goStore(JCBLasfaCceGDZIr, "");
        }
        break;
      case TargetPlatform.iOS:
        if (EohTKnJmAJrshQrh != null) {
          JiUPFiuyXhbfRbkE(fgkGhXwxpAEexaex: (dialog) {
            AppInstaller.goStore("", EohTKnJmAJrshQrh);
          });
        }
        break;
      case TargetPlatform.fuchsia:
        break;
      case TargetPlatform.linux:
        break;
      case TargetPlatform.macOS:
        break;
      case TargetPlatform.windows:
        break;
    }
  });
}