我正在嘗試同時遍歷兩個串列
例如
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”回圈中同時遍歷兩個串列。
uj5u.com熱心網友回復:
這是代碼:
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]}");
}
如果這沒有幫助,請告訴我。
uj5u.com熱心網友回復:
final c = zip([a, b]).map((item) => Foo(item[0], item[1])).toList();
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/330686.html
