To create a three-dimensional list in Dart, you can use nested List structures to represent the multi-dimensional data.
In this example,
void main() {
List<List<List<int>>> threeDList = [];
for (int i = 0; i < 3; i++) {
List<List<int>> plane = [];
for (int j = 0; j < 2; j++) {
List<int> row = [];
for (int k = 0; k < 2; k++) {
row.add(i * 4 + j * 2 + k + 1);
}
plane.add(row);
}
threeDList.add(plane);
}
for (var plane in threeDList) {
for (var row in plane) {
print(row);
}
print('');
}
}
[1, 2] [3, 4] [5, 6] [7, 8] [9, 10] [11, 12]
In this tutorial, we learned How to create a Three Dimensional List in Dart language with well detailed examples.