why flutter application can't connect to internet when install app-release.apk? but normal in debug mode

放肆的年华 提交于 2019-12-30 08:13:42

问题


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

here is my code

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();
                },
              );
            }
        }
      },
    );
  },
),

回答1:


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"/>



回答2:


add to android/app/src/main/AndroidManifest.xml after package name




回答3:


If you had put

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

on AndroidManifest.xml

And If it's not working

Try checking connectivity of device. Mobile data or WiFi on android device. Try using chrome browser for google search If it's not working

allow

8.8.8.8

in DNS setting of computer you are using.



来源:https://stackoverflow.com/questions/55603979/why-flutter-application-cant-connect-to-internet-when-install-app-release-apk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!