繁体   English   中英

我是 Flutter 的新手。我想将 JSON 数据显示为 flutter 中的列表,但我不知道如何编码以将 JSON 数据显示为 Flutter 中的列表

[英]I am New in Flutter. I want to display JSON Data as List in flutter but I do not know how to Coding for show JSON data as a List in Flutter

我想将此 JSON 数据显示为 Flutter 中的列表。我有 JSON 数据,但我不知道如何将 JSON 数据显示为 Flutter 中的列表。

这是 JSON 文件:

[
{
    "id": 2,
    "Name": "Ramesh Shah",
    "Activity_Type": "Highseverity",
    "Description": "Try to Send data using Chrome",
    "Date": "2022-02-03T11:31:00Z"
},
setState(() {
  data = jsonDecode(jsonData);
});

您可以使用 JSON 解码器从 JSON 数组创建 flutter object

 @override
      Widget build(BuildContext context){
        return new Scaffold(
          appBar: new AppBar(title: new Text("Listviews"), backgroundColor: Colors.blue),
          body: new ListView.builder(
            itemCount: data == null ? 0 : data.length,
            itemBuilder: (BuildContext context, int index){
              return new Card(
                child: new Text(data[index]["title"]),
              );
            },
          ),
        );
      }
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM