flutter - 如何同时循环两个列表 - Flutter

标签 flutter dart

我试图同时遍历两个列表

例如

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/

相关文章:

Flutter PageView 如何在滑动时制作更快的动画

flutter - 在 Flutter 上模拟 getExternalStorageDirectory

Dart 使用公钥和私钥对字符串进行加密和解密

android - flutter中实现自定义底部导航栏

dart - 从 map 上删除元素

flutter - 处理水平步进器的溢出

flutter - 具有不等权重元素的行

dart - AngularDart将切换事件从一个组件传递到另一个组件

dart - Dart 标准库中是否有类似于动词或 mustache 的东西,我可以用它来从模板生成文本文件?

http - flutter http发送空正文