为什么在安装app-release.apk时flutter应用程序无法连接到Internet?但在调试模式下正常 [英] why flutter application can't connect to internet when install app-release.apk? but normal in debug mode

查看:281
本文介绍了为什么在安装app-release.apk时flutter应用程序无法连接到Internet?但在调试模式下正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调试模式下,一切看起来都不错,请从我的API获取响应和数据列表.但是,在构建app-release.apk并安装到手机上之后,它显示没有互联网连接

when in debug mode everything looks good, get response and lists of data from my API. But after I build app-release.apk and install to my phone, it shows no internet connection

这是我的代码

ScopedModelDescendant<ReportPosViewModel>(
  builder: (context, child, model) {
    return FutureBuilder<List<Invoice>>(
      future: model.invoices,
      builder: (_,
          AsyncSnapshot<List<Invoice>> snapshot) {
        switch (snapshot.connectionState) {
          case ConnectionState.none:
          case ConnectionState.active:
          case ConnectionState.waiting:
            return Center(
                child:
                    const CircularProgressIndicator());
          case ConnectionState.done:
            if (snapshot.hasData) {
              //something todo
            } else if (snapshot.hasError) {
              return NoInternetConnection(
                action: () async {
                  await model.setInvoice();
                  await getData();
                },
              );
            }
        }
      },
    );
  },
),

推荐答案

android/app/src/mainAndroidManifest.xml文件中,您需要在<manifest标记中添加此权限.

In the AndroidManifest.xml file located at android/app/src/main you need to add this permission in <manifest tag.

<uses-permission android:name="android.permission.INTERNET"/>

这篇关于为什么在安装app-release.apk时flutter应用程序无法连接到Internet?但在调试模式下正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆