Flutter automatically update application when new version is available

前端 未结 5 1817
轮回少年
轮回少年 2021-02-05 17:14

How can I implement auto-updating of my application when a new version is released without using Google Play Store? I\'m using JSON to check the version.

5条回答
  •  离开以前
    2021-02-05 17:54

    Maybe this help you

    Backend backend = Backend.instance();
    PackageInfo packageInfo = await PackageInfo.fromPlatform();
    String packageName = packageInfo.packageName;
    
    Response r;
    try {
    
      r = await backend.io.get("https://play.google.com/store/apps/details?id=$packageName&hl=en");
      if(r.statusCode == 200){
        String data = r.data;
    
        String pat1 = 'Current Version
    '; String pat2 = ''; int p1 = data.indexOf(pat1) + pat1.length; String f = data.substring(p1, data.length); int p2 = f.indexOf(pat2); String currentVersion = f.substring(0, p2); return currentVersion; } return null; } catch (e) { errors = backend.interceptor.errors; return null; }

提交回复
热议问题