Limbou / expandable_page_view

MIT License
86 stars 36 forks source link

Add support to Instrinsic Height #46

Closed balaji101010 closed 1 year ago

balaji101010 commented 2 years ago

Is it possible to add instrinsic height support?

 return IntrinsicHeight(
      child: ExpandablePageView(
        children: [
          Container(
            color: Colors.pinkAccent,
            height: 200,
          ),
          Container(
            color: Colors.greenAccent,
            height: 150,
          ),
          Container(
            color: Colors.blueGrey,
            height: 340,
          ),
        ],
      ),
    );

Expected result is all the children should get the taller child's height

Limbou commented 1 year ago

Hi @balaji101010, material PageView is built in a way that does not work with IntrinsicHeight. Even if I was able to create such functionality, it would only work with regular ExpandablePageView constructor and would not work with .builder because in the latter case we would not know the sizes of all children because they are not laid out yet.

Because of the inconsistencies it would introduce (would work with one constructor but wouldn't work with the other) I need to resign from implementing this feature.

To suggest some solution, maybe you could use a regular PageView, collect all your children sizes after they are first built using WidgetsBinding.instance.addPostFrameCallback and set your PageView's size to match the biggest child.

I'm going to close this issue for now, let me know if you have any other questions.