如何组织`List<List<String>>`类型的数据

How to organize the data of type `List<List<String>>`

我有 List<List<String>> 来自 Map<String, dynamic>

这里是List<List<String>>
的代码 tab 是 Tablet Class.

类型的对象
Map<String, dynamic> demo = {'Uses': [tab.usesTitle, tab.usesBody], 'Safety Advices': [tab.safetyAdvTitle, tab.safetyAdvBody]};

平板电脑对象

Tablet tab = Tablet(
    usesTitle:  ['Pain Relief', 'Fever'],
    usesBody:  ['Pain Relief Details.....', 'Fever Details.....'],
    safetyAdvTitle:  ['Alcohol','Kidney' ],
    safetyAdvBody:  ['Alcohol Details...', 'Kidney Details...'],
);

我试过的

demo.forEach((k, v){
    v.forEach((y){
      print(y.join('\n'));
    });
});

当前输出

Uses
Pain Relief
Fever
Pain Relief Details.....
Fever Details.....
Safety Advices
Alcohol
Kidney
Alcohol Details...
Kidney Details...

我要这样

Uses
Pain Relief
Pain Relief Details.....
Fever
Fever Details.....

Safety Advices
Alcohol
Alcohol Details...
Kidney
Kidney Details...

Actually It's demo So just printing values. In real World, I am going to use Widgets. So At that time forEach . So solution without forEach needed.

已更新
我可以执行下拉功能,但 Text() 小部件应按此顺序一一对齐。
在这张下面还有一张卡片,上面有 安全建议 ,设计相同。

你为什么要避免 forEach,无论你有数组,你也可以有 forEachmap 等,

试试这个,

Map<String, dynamic> demo = {
  'Uses': [
    ['Pain Relief', 'Fever'],
    ['Pain Relief Details.....', 'Fever Details.....'],
  ],
  'Safety Advices': [
    ['Alcohol', 'Kidney'],
    ['Alcohol Details...', 'Kidney Details...']
  ]
};


List<Widget> widgets = [];

demo.forEach((key, value) {
  for (int i = 0; i < value[0].length; i++) {
    for (int j = 0; j < value.length; j++) {
      // Inside this loop, j = 0 means your Heading and j = 1 means the content
      widgets.add(Text(
        (value[j] as List)[i],
        style: TextStyle(fontWeight: j == 0 ? FontWeight.bold : null),
      ));
    }
  }
});

然后,使用您制作的小部件数组作为 childrenColumn

这将是输出。