Log flutter app detection update (internal update only)

Directly upload the code, paste and copy to use: 
import 'package:get/get.dart'; 
import 'package:package_info/package_info.dart';
class AppUtils {
  static checkUpdate() async {
    PackageInfo info = await PackageInfo.fromPlatform();
    dynamic ui = await HttpUtils.get(PortAddress.QY_UPDATE);
    if(ui != null) {
      if (info.version != ui['os-version']) {
        Get.dialog(WillPopScope(
          onWillPop: notWillPop,
          child: AlertDialog(
            title: Text('发现新版本 V' + ui['os-version']),
            content: AppUpdate(url: ui['url'], updateInfo: ui['update-info'],
              fileName: 'app' + '.' + ui['os-version'] + '.' +
                  '1' + '.apk',),
          ),
        )
        );
      }
    }
  }

  static Future<bool> notWillPop() async {
    return false;
  }
}
import 'dart:io';
import

Guess you like

Origin blog.csdn.net/wxx314165038/article/details/120916279