在调试模式下,一切看起来都很好,从我的API获取响应和数据列表。但是在我构建app-release.apk并安装到我的手机后,它显示没有互联网连接
这是我的代码
ScopedModelDescendant(
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();
},
);
}
}
},
);
},
),
在位于AndroidManifest.xml
的android/app/src/main
文件中,您需要在<manifest
标记中添加此权限。
<uses-permission android:name="android.permission.INTERNET"/>
在包名后添加到android / app / src / main / AndroidManifest.xml