Arash
Arash

Reputation: 12425

How to use Pageable lazy list

I want to create a very long list of widgets that is user might want to scroll through, like a book. I noticed PageableLazyList class, but couldn't quite understand how should I use it.

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;
  }


}

didn't work! I need a build method here, but couldn't understand what I am supposed to do.

Upvotes: 2

Views: 158

Answers (1)

Arash
Arash

Reputation: 12425

Well this actually works:

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;
  }


}

Upvotes: 3

Related Questions