Search code examples
flutterdartflutter-layoutflutter-listviewflutter-pageview

Wrap item different height in vertical PageView - Flutter


I have a vertical PageView with different item height :

enter image description here

But I would like to wrap each item according their height.

The final result I want here:

enter image description here

How can we do this ?


Solution

  • UPDATE 2022:

    After some time, I returned to this problem and have now created a smart and slim pub.dev package with way more features, less buggy, and maintained code.

    SnappyListView(
      itemCount: Colors.accents.length,
      itemBuilder: (context, index) {
        return Container(
            height: 100,
            color: Colors.accents.elementAt(index),
            child: Text("Index: $index"),
        ),
    );
    

    For those still interested in a non-packages solution (not recommended), make sure to check out the edit queue of this answer.