Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app启动时并不会弹框出来说更新 #7

Closed
qq329401134 opened this issue Apr 27, 2020 · 5 comments
Closed

app启动时并不会弹框出来说更新 #7

qq329401134 opened this issue Apr 27, 2020 · 5 comments

Comments

@qq329401134
Copy link

qq329401134 commented Apr 27, 2020

用ctrl+shift+\方式刷新的时候app启动会弹框出来说更新
用debug模式也会弹出来
但是将app安装在手机上然后重新打开的时候并没有什么反应,不知道为什么。但是切换到后台然后再切回来会立马又弹出来,不知道为什么
image
加上这一句就会出现这个问题
@781238222

@xxNull-lsk
Copy link

把AppUpgrade.appUpgrade放到setState里面应该就没有这个问题了。例如:
setState(() {
AppUpgrade.appUpgrade(context, getUpgradeInfo, cancelText: '以后再说', okText: '马上升级');
});

@MakenChan
Copy link

用ctrl+shift+\方式刷新的时候app启动会弹框出来说更新
用debug模式也会弹出来
但是将app安装在手机上然后重新打开的时候并没有什么反应,不知道为什么。但是切换到后台然后再切回来会立马又弹出来,不知道为什么
image
加上这一句就会出现这个问题
@781238222

我也遇到这个问题,因为请求是异步的,请问怎么解决的这里

@MakenChan
Copy link

getUpgradeInfo

请问加在那个state里面,加了也还是一样,首页不出来,要点击或者切换后台才会弹出一个升级框

@MakenChan
Copy link

可以这样解决,启动的时候先加载值设置为静态,使用的时候取值
void main() {
realRunApp();
}
void realRunApp() async {
//初始化升级
await SpUtils.getInstance();
runApp(MyApp());
}

SpUtils.dart
class SpUtils {
static Map result;
static AppInfo appInfo;

static Future getInstance() async {
result = await NetUtils.request(Constants.SERVER_URL+"/api/basis-app/version/latest");
return true;
}

static Future getInstanceInfo() async {
appInfo = await FlutterUpgrade.appInfo;
return true;
}
}

@LaoMengFlutter
Copy link
Owner

1.1.0版本已经修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants