【发布时间】:2021-07-06 18:21:16
【问题描述】:
当我想从一个 json 表单中获取一个值时,我遇到了这个错误,上面写着 type 'String' is not a subtype of type 'int' of 'index' 什么是问题?我正在使用http: ^0.12.0+2 包
this is the output of the program
这是我使用的代码:
void getData() async{
Response res=await get("https://jsonplaceholder.typicode.com/posts");
String dat=res.body;
var datta=jsonDecode(dat)['title'];
print(datta);
}
【问题讨论】:
-
尝试转换为字符串。因此:value.toString();