【发布时间】:2021-09-12 12:07:43
【问题描述】:
假设我有一个如下的小部件列表:
List<Widget> widgets = [Row(1), Row(2), Row(3), ...... Row(30)];
现在我想将此列表分成多个页面。像这样:
PageView(
children: [
Page1(), // lets say this page contains rows 1 to 7
Page2(), // lets say this page contains rows 8 to 13
Page3(), // this contains the remaining rows 14 - 30
]
)
现在,如果所有行都具有相同的高度,这将很容易解决。 但就我而言,行的高度可能会有所不同。
问题是我不知道每个页面可以容纳多少行,因为颤振没有提供任何计算小部件高度的好方法。
任何有关如何解决此问题的建议将不胜感激。
【问题讨论】:
-
制作一个具有固定最大高度的容器,然后将 Center 作为具有 Row 作为子级的子级,嵌套如下: Container(height:maxHeight child: Center(child:Row()))