開發工具中顯示的錯誤訊息我正在嘗試在 Flutter 中執行 PHP 檔案。我擁有的代碼是:
class _MyAppState extends State<MyApp> {
@override
var url = 'http://localhost/myDashFolder/getdata.php';
Future<List> getData() async {
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
return json.decode(response.body);
}
else {
throw Exception("Response content length is ${response.statusCode}, failed to get any details.");
}
}
在開發工具中,獲取請求顯示錯誤。但是,當我手動執行相同的操作時,它可以作業。
我究竟做錯了什么?
uj5u.com熱心網友回復:
網址 = http://10.0.2.2/myDashFolder/getdata.php
嘗試在您的模擬器中使用上述 URL。
來源:LINK
如果解決方案不起作用,請發表評論。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/449833.html
