我试着用其他类的列表制作网格
-- Gridview部分
GridView.builder(
shrinkWrap: true,
itemCount: iLength,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: iRow, childAspectRatio: iSep.toDouble()*0.5, crossAxisSpacing: 5, mainAxisSpacing: 15),
itemBuilder: (context, sec_index) {
//setState(() {});
return GridView.builder(
itemCount: iSep,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: iSep,
childAspectRatio: 0.5,
crossAxisSpacing: 0,
mainAxisSpacing: 10),
itemBuilder: (context, sep_index) {
int index1 = sec_index + 1;
int index2 = sep_index + 1;
var inst = Note(Sec: index1, Sep: index2);
AppValues().list_Note.add(inst); // this list. i added
print("Length : " + AppValues().list_Note.length.toString()); // check
//AppValues().list_Note.
return inst;
},
);
},
);
-- Other class,has list
class AppValues {
AppValues();
int Grid_Row = 15;
int NoteSepreated = 1;
int NoteLength = 50;
NScript SelectScript = NScript.none;
double PlaySpeed = 1.0;
double PlaySpeed_Default = 1.0;
double PlaySpeed_Min = 0.0;
double PlaySpeed_Max = 2.0;
List<Note> list_Note = List.empty(growable: true); // here
}
--结果打印
正在执行热重新加载...正在将文件同步到设备Windows. flutter:长度:0Flutter:长度:0Flutter:长度:0Flutter:长度:0Flutter:长度:0Flutter:长度:0Flutter:长度:0Flutter:长度:0Flutter:长度:0Flutter:长度:0Flutter:长度:0在238毫秒内完成了969个库中的1个(编译:23 ms,重新加载:71 ms,重新组装:92 ms)。
我很生气。我怎么了?这是setState()问题吗?
我不知道还有什么别的选择
1条答案
按热度按时间cwtwac6a1#