如何滚动嵌套在Flutter中的Listview [英] How to scroll Listview nested in Flutter
本文介绍了如何滚动嵌套在Flutter中的Listview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用两个嵌套的Listviews和ListView.builder时,它仍会滚动,但是具有shirnkSwap属性的子Listview.builder无法再滚动,但是我不想在小部件容器中使用height属性,因为它是非常难看.
When I use two nested Listviews and ListView.builder it still scroll, but the child Listview.builder with the shirnkSwap property cannot be scrolled anymore, but I don't want to use the height attribute in the widget container because it is very ugly.
Flutter 1.9.4 SDK
Flutter 1.9.4 SDK
//我的主屏幕
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xFFEEF0F2),
appBar: AppBar(
backgroundColor: Color(0xFF396DF0),
elevation: 0,
leading: LeadinguttonIcon(),
title: Text('TheGoal'),
actions: <Widget>[ActionIconButton()],
),
body:
ListView(children: <Widget>[TopHomeScreenBody(), BottomHomeScreen()]),
);
}
}```
**// TopHomeScreenBody**
```class TopHomeScreenBody extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ClipPath(
clipper: BodyClipper(),
child: Container(
color: Color(0xFF396DF0),
padding: EdgeInsets.only(top: 10, right: 22, left: 22, bottom: 30),
height: 250,
width: double.infinity,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(15))),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[MainText(), SubText()],
),
),
),
);
}
}```
**// BottomHomeScreen**
```class BottomHomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
// IT CAN SCROLL WHEN ADD HEIGHT BUT I
// DONT WANT USE HEIGHT HERE BECAUSE VERY UGLY APP
// height: 400,
padding: EdgeInsets.all(25),
decoration: BoxDecoration(
color: Color(0xFFEEF0F2),
),
child: ListView.builder(
shrinkWrap: true,
itemBuilder: (context, index) {
return BottomGoalTitle(
text: '${goalList[index].text}',
decsText: '${goalList[index].decsText}',
color: goalList[index].color,
icon: goalList[index].icon,
);
},
itemCount: goalList.length,
),
);
}
}
感谢您的阅读.希望您的帮助!
Thank you for reading. Hope your help!
推荐答案
如果您不想让listview.builder
滚动,请尝试添加此physics: NeverScrollableScrollPhysics(),
If you mean that you dont want your listview.builder
to scroll try adding this physics: NeverScrollableScrollPhysics(),
这篇关于如何滚动嵌套在Flutter中的Listview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文