在Flutter / Dart中创建2D数组 [英] Creating a 2d array in flutter / dart
本文介绍了在Flutter / Dart中创建2D数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是扑扑和飞镖的新手。我已经搜索过Google,而我所能找到的就是如何快速建立一维列表。我需要一个值图表。
I'm brand new to flutter and dart. I've searched google and all I can find is how to make 1d lists in flutter. I need a chart of values.
特别是我需要一行12长,一列31长,并用升序填充
Specifically I need a row 12 long and a column 31 long filled with ascending numbers
1, 32, 63,
2, 33, 64,
3, 34, 65, etc....
谢谢!
推荐答案
int row = 3;
int col = 4;
var twoDList = List.generate(row, (i) => List(col), growable: false);
//For fill;
twoDList[0][1] = "deneme";
print(twoDList);
// [[null, deneme, null, null], [null, null, null, null], [null, null, null, null]]
您的二维列表具有3行4列。
Your 2D list having 3 rows and 4 columns.
这篇关于在Flutter / Dart中创建2D数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文