我想创建一个很长的小部件列表,用户可能想要滚动浏览,就像一本书。 我注意到了PageableLazyList类,但我不太明白应该如何使用它。
class NotePage extends PageableLazyList {
NotePage({Key key, this.note}) : super(key: key,itemBuilder: itembuilder);
final Note note;
static List<NoteContainer> itembuilder (BuildContext context, num start, num count ){
List<NoteContainer> result = <NoteContainer>[];
for(num i = start; i < start+count; i++){
result.add(new NoteContainer(new Note(title: "Note " + i.toString(), description: "Description " + i.toString())));
}
return result;
}
}
没有用!我在这里需要一个构建方法,但无法理解我应该做什么。
答案 0 :(得分:2)
这实际上有效:
class NotePageList extends PageableLazyList {
NotePageList({Key key}) : super(key: key,
scrollDirection: Axis.horizontal,
itemCount : 10000,
itemBuilder: itembuilder){
}
static List<NoteContainer> itembuilder (BuildContext context, num start, num count ){
List<NoteContainer> result = <NoteContainer>[];
for(num i = start; i < start+count; i++){
result.add(new NoteContainer(new Note(title: "Note " + i.toString(), description: "Description " + i.toString())));
}
return result;
}
}