我想将数据库中的所有 json 数据显示到表中,但我很困惑 json 的解决方案是纯文本。我不太了解使用 Map ,因为这会使我的代码出错
FutureBuilder(
future: UserController.getActivity(_selectedUser),
builder: (context, snapshot) {
if (snapshot.hasData) {
var item = snapshot.data;
Map<String, dynamic> activity = item[snapshot]['activity'];
//print(snapshot.data.toString());
print(activity);
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Table(
defaultColumnWidth: FixedColumnWidth(150.0),
border: TableBorder(
horizontalInside: BorderSide(
color: Colors.black,
style: BorderStyle.solid,
width: 1.0,
),
verticalInside: BorderSide(
color: Colors.black,
style: BorderStyle.solid,
width: 1.0,
),
),
children: [
TableRow(children: [
TableCell(
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: <Widget>[
new Text(snapshot.data["project"]),
],
),
)
])
],
)
],
);
} else {
return Center(
child: Text("No data displayed"),
);
}
},
),
当我尝试使用此代码时出现错误_FutureBuilderState # 71363): Expected a value of type 'int', but has one type of 'AsyncSnapshot'