我试图同时遍历两个列表
例如
List A = ['Chapter 1','Chapter 2','Chapter 3'];
List B = ['Paragraph 1','Paragraph 2','Paragraph 3'];
for(var chapter in A) // This would itreate through only first list (A), How can I iterate through both list
children: [
Text(chapter);
Text(paragraph);
]
我需要在“for”循环中同时遍历两个列表。
最佳答案
代码如下:
List A = ['Chapter 1','Chapter 2','Chapter 3'];
List B = ['Paragraph 1','Paragraph 2','Paragraph 3'];
for (int i = 0; i < A.length; i++) {
print ("${A[i]}");
print ("${B[i]}");
}
如果这没有帮助,请告诉我。
关于flutter - 如何同时循环两个列表 - Flutter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69666420/