5

I have an indexed stack. First child widget has half the content that the second child widget has, but the first child widget's height is the same as the second child widget. This seems to be the expected result due to the design but its annoying because when I scroll on the first child widget, there is a bunch of extra space at the bottom. How can I work around this?

Why did the Flutter team even design it like this? Why not give the widget children the height according the the widgets, not according to whatever the largest child is?

TortillaPack
  • 95
  • 1
  • 9

2 Answers2

1

Co ask. I am experiencing this problem when I have the index stack as one of the slivers in a custom scroll view. The children are wash scrollable lists. So when one child of the indexed stack has more items in its list than the other, there is extra white space at the bottom

kingkobain99
  • 65
  • 2
  • 7
1

I faced the exact same issue today. My workaround is to only render the Stack which is visible based on the index number.

      Widget _buildPage2() {
        if(index != 1) { // Empty container
          return Container();
        }
        return Column( // Actual Widget which has a different height
          children: <Widget>[]
        );
     }

I still have not figured out how to get controller.animateTo working.

Edit

I got controller.animateTo to work by triggering a Future.delayed event. As a better approach you could use WidgetBindings, as explained in this other post.

Souvik Das
  • 36
  • 5