1
我想从异步函数返回一个字符串,但我得到一个未来 我做错了什么;从异步返回字符串
例
main() {
String s;
s = dummy("http://www.google.com");
}
String dummy(String s) {
String response;
response = readURL(s);
return (response);
}
Future<String> readURL(String requestString) async {
String response = await http.read(requestString);
print(response);
return(response);
}
错误:
type '_Future' is not a subtype of type 'String' of 'response'.