![](/img/trans.png)
[英]While trying to make splash screen with in flutter I am getting an error 255 how do I fix it?
[英]I am having an error while trying to make a get request on flutter
String url = 'http://localhost:9000/user/john.doe@email.com';
Future<String> get makeRequest() async {
var response = await http
.get(Uri.encodeFull(url), headers: {"Accept": "application"});
print(response.body);
}
我在 makeRequests() 上收到一條錯誤消息,上面寫着“這個 function 的返回類型為 'Future',但不以返回語句結尾。”
您必須在 function 和 header Future<String> 中返回一個字符串。 您可能想返回 response.body
您必須返回與 function 的返回類型對應的數據。
String url = 'http://localhost:9000/user/john.doe@email.com';
Future<String> get makeRequest() async
{
var response = await http.get(Uri.encodeFull(url), headers: {"Accept": "application/json"});
print(response.body);
return(response.body);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.