【发布时间】:2021-12-05 07:51:43
【问题描述】:
以下示例在 sdk: ">=2.7.0
创建新项目后 SDK 默认为 sdk: ">=2.12.0
调用signIn后,旧项目登录工作正常。有什么解决办法吗?
signIn(String email, String password, BuildContext context) async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
var jsonResponse = null;
var response = await http.get(Uri.https('myrl', 'login' + '$email/$password'));
if (response.statusCode == 200) {
jsonResponse = json.decode(response.body);
if (jsonResponse != null) {
sharedPreferences.setString("email_token", email);
Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: (context) => MyApp()
));
}
} else {
txtPassword.clear();
}
}
注意
在模拟器上工作,但在构建 apk 并在点击登录按钮并调用登录后在移动设备上运行后什么都没有。
编辑
在权限下添加 AndroidManifest.xml 后工作正常。
android.permission.INTERNET
【问题讨论】: