Flutter 在向上滑动面板中使用listview.builder进行颤振(溢出的RenderFlex的方向为Axis.vertical)
我有一个向上滑动的面板,它的面板是柱状的。。子对象是一个列表视图生成器,带有容器包装。。但我犯了这个错误Flutter 在向上滑动面板中使用listview.builder进行颤振(溢出的RenderFlex的方向为Axis.vertical),flutter,dart,Flutter,Dart,我有一个向上滑动的面板,它的面板是柱状的。。子对象是一个列表视图生成器,带有容器包装。。但我犯了这个错误 The following assertion was thrown during layout: A RenderFlex overflowed by 2.0 pixels on the bottom. The relevant error-causing widget was: Column 这是我的滑动部件 Widget _slidingUpWidget(){ retur
The following assertion was thrown during layout:
A RenderFlex overflowed by 2.0 pixels on the bottom.
The relevant error-causing widget was:
Column
这是我的滑动部件
Widget _slidingUpWidget(){
return Container(
child: SlidingUpPanel(
minHeight: MediaQuery.of(context).size.height / 2,
panel: Column(
children: [
userResponseWidget(),
//caption
textWidget(),
// divider
dividerWidget(),
//comment
commentSectionWidget(dataComment),
//write comment
_floatingTextfieldWidget()
],
)
)
);
}
这是列表视图生成器
Widget commentSectionWidget(Comment data){
return Container(
child: ListView.builder(
physics: NeverScrollableScrollPhysics(),
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: data.data.length,
itemBuilder: (_, index) {
return Container(
child: ItemComment(data.data[index]),
);
}
),
);
}
我尝试过用Expanded()
包装容器,但它只显示了一半内容,不可滚动。。我也使用了SingleChildScrollView()
,但它返回了很多错误
有人能帮你修好吗?在
列的上方添加SingleChildSrollView
,现在它应该对你有用了
代码:
Widget _slidingUpWidget(){
return Container(
child: SlidingUpPanel(
minHeight: MediaQuery.of(context).size.height / 2,
panel: SingleChildScrollView(
child: Column(
children: [
userResponseWidget(),
//caption
textWidget(),
// divider
dividerWidget(),
//comment
commentSectionWidget(dataComment),
//write comment
_floatingTextfieldWidget()
],
),
)
)
);
}
将SingleChildSrollView
添加到Column
上方,现在它应该适合您了
代码:
Widget _slidingUpWidget(){
return Container(
child: SlidingUpPanel(
minHeight: MediaQuery.of(context).size.height / 2,
panel: SingleChildScrollView(
child: Column(
children: [
userResponseWidget(),
//caption
textWidget(),
// divider
dividerWidget(),
//comment
commentSectionWidget(dataComment),
//write comment
_floatingTextfieldWidget()
],
),
)
)
);
}
由于NeverScrollableScrollPhysics()的原因,它不可滚动。由于SlidengAppAnel minHeight的原因,它显示了一半的内容。还包括所有容器()。他们什么也没做。如果确实需要包装,请使用SizedBox()。删除Listviewbuilder中的包覆面提取true,因为您使用了expandedit,由于NeverScrollableScrollPhysics()而无法滚动它显示了一半的内容,因为SlidingUpPanel minHeight。还包括所有容器()。他们什么也没做。如果确实需要包装,请使用SizedBox()。在Listviewbuilder中删除包络处理true,因为您使用了展开