gpt4 book ai didi

listview - 如何滚动嵌套在Flutter中的Listview

转载 作者:行者123 更新时间:2023-12-03 04:10:17 25 4
gpt4 key购买 nike

当我使用两个嵌套的 Listviews 和 ListView.builder 时它仍然滚动,但是具有 shirnkSwap 属性的子 Listview.builder 不能再滚动,但我不想在小部件容器中使用高度属性,因为它是很丑。

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,
),
);
}
}

感谢阅读。希望得到您的帮助!

最佳答案

如果你的意思是你不想让你的 listview.builder 滚动尝试添加这个 physics: NeverScrollableScrollPhysics(),

关于listview - 如何滚动嵌套在Flutter中的Listview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58424109/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com