我想要嵌套列表,其中水平列表视图内会有垂直列表

我想要嵌套列表视图,其中水平列表视图中会有垂直列表视图,并且将用 SingleChildScrollView 包裹,因为我想一起滚动所有垂直列表。

这就是我所做的

Expanded(
                    child: Stack(
                  children: [
                    Container(
                      height: double.infinity,
                      width: double.infinity,
                      decoration: BoxDecoration(
                          gradient: LinearGradient(
                        begin: Alignment.topCenter,
                        end: Alignment.bottomCenter,
                        colors: [
                          Theme.of(context).primaryColorDark,

图片[1]-我想要嵌套列表,其中水平列表视图内会有垂直列表-唐朝资源网

Theme.of(context).primaryColorLight, ], )), ), SingleChildScrollView( scrollDirection: Axis.vertical, physics: const BouncingScrollPhysics(), child: SizedBox( height: 200.w, child: ListView.builder( scrollDirection: Axis.horizontal, physics: const BouncingScrollPhysics(), itemCount: 5, itemBuilder: (context, index) { return SizedBox( height: double.infinity, width: 24.w, child: Column( children: [ Container( width: double.infinity, padding: EdgeInsets.fromLTRB( 0.w, 3.w, 0, 3.w), color: Colors.white, child: Center(child: Text("Header"))), ListView.builder( physics: const NeverScrollableScrollPhysics(), itemCount: 20, shrinkWrap: true, itemBuilder: (context, index) { return GestureDetector( onTap: () {}, child: Padding( padding: EdgeInsets.fromLTRB(

图片[2]-我想要嵌套列表,其中水平列表视图内会有垂直列表-唐朝资源网

0.w, 2.w, 0.w, 2.w), child: Center( child: Text( "8:44", style: TextStyle( color: Colors.white, fontSize: 14.sp)), ), ), ); }, ) ], ), ); }, ), )) ], ))

预期输出:

但是,如果我不将垂直列表视图放在 SizedBox 中并且不给出固定高度,那么它会导致问题。

我想在列表视图中垂直扩展或类似 wrap_content 的内容,以便它自己占用所需的空间。

那我该怎么办?有人可以帮忙吗?

提前致谢。

© 版权声明
THE END
喜欢就支持一下吧
点赞187赞赏 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容