我的代码:
import 'package:http/http.dart' as http;
import 'dart:convert';
void main()async {
var data =await fatchalbum();
for(int i =0; i>100;i++){
print(data[i]["userId"]);
print(data[i]["id"]);
print(data[i]["title"]);
}
}
Future fatchalbum()async{
final url ="https://jsonplaceholder.typicode.com/albums";
final res = await http.get(Uri.parse(url));
if(res.statusCode==200){
var obj = json.decode(res.body);
return obj;
}else{
throw Exception("error");
}
}
如果我在“主函数”中写入 print("hi");
它可以在调试控制台中运行 "hi"
它不显示其余数据
当我运行代码时,调试控制台中出现此错误
Failed to save Chrome preferences: FileSystemException: Cannot open file, path = 'C:\Users\dell\AppData\Local\Temp\flutter_tools.ab04b1f8\flutter_tools_chrome_device.49e73a42\Default\Cache\data_0' (OS Error: The process cannot access the file because it is being used by another process.
, errno = 32)
有时当我按下停止然后按下 Run&Debuge 它只显示我,它没有显示我想要的输出:
This app is linked to the debug service: ws://127.0.0.1:55071/6_DbR0EpDJg%3D/ws
Launching lib\main.dart on Edge in debug mode...
lib\main.dart:1
Debug service listening on ws://127.0.0.1:55071/6_DbR0EpDJg=/ws
Running with sound null safety
Connecting to VM Service at ws://127.0.0.1:55071/6_DbR0EpDJg=/ws