循环槽对象以在dart中创建容器

循环槽对象以在dart中创建容器,dart,Dart,我正在为一个网站和一个应用程序编写代码。我精通PHP,但不熟悉dart。网站和应用程序都会调用API来获取应该显示的数据。在PHP中,我使用foreach循环遍历并回显每个键的div,如下所示: # res is an example string for an api result $res = '{"first":["ExampleTitle", "ExampleDescription"], "second":[

我正在为一个网站和一个应用程序编写代码。我精通PHP,但不熟悉dart。网站和应用程序都会调用API来获取应该显示的数据。在PHP中,我使用foreach循环遍历并回显每个键的div,如下所示:

# res is an example string for an api result
$res = '{"first":["ExampleTitle", "ExampleDescription"], "second":["ExampleT2", "ExampleD2"], "third":["ExpampleT3", "ExampleD3"]}';
$res = json_decode($res);

foreach ($res as $key => $value) {
  echo '<div style="margin-bottom: 35px;">'.$value[0].'<br>'.$value[1].'</div>';
}
ExampleTitle ExampleDescription ExampleT2 ExampleD2 ExpampleT3 ExampleD3
#res是api结果的示例字符串
$res='{“first”:[“exampletTitle”,“exampledDescription”],“second”:[“ExampleT2”,“ExampleD2”],“third”:[“ExpampleT3”,“ExampleD3”]};
$res=json_解码($res);
foreach($res作为$key=>$value){
回显“.$value[0]”。
“.$value[1]”; }
输出如下所示:

# res is an example string for an api result
$res = '{"first":["ExampleTitle", "ExampleDescription"], "second":["ExampleT2", "ExampleD2"], "third":["ExpampleT3", "ExampleD3"]}';
$res = json_decode($res);

foreach ($res as $key => $value) {
  echo '<div style="margin-bottom: 35px;">'.$value[0].'<br>'.$value[1].'</div>';
}
ExampleTitle ExampleDescription ExampleT2 ExampleD2 ExpampleT3 ExampleD3 示例标题 示例说明 例2 例2 ExpampleT3 例3 现在我想在应用程序中使用dart做同样的事情。如何通过循环对象来创建多个容器


换句话说:dart代码除了不创建div而创建容器之外,还能实现与PHP代码相同的功能吗?

在flutter中无法处理类似html的数据。您的api应该以json的形式返回数据,您应该在Flatter中转换数据并相应地构建ui。这可能有助于回答您的问题:@Adnan数据采用正确的json格式,这不是问题所在,但链接页面仍然有用。非常感谢。