首页 > 解决方案 > SingleChildScrollView 的问题 - Flutter

问题描述

我试图让一个容器固定,而屏幕的另一部分可以进行一些滚动,是否有可能复制不是屏幕,只有这两个事件? 在此处输入图像描述

return SingleChildScrollView(
  physics: NeverScrollableScrollPhysics(),
      child: Container(
    child: Column(
      children: <Widget>[
        Container(
          height: 200,
          width: double.infinity,
          color: Colors.red,
        ),
        SingleChildScrollView(


          child: Container(color: Colors.blue,height: 1000,width: double.infinity,))
       /*  body(context, screenWidth, screenHeight),
        bottmtop(context), */
      ],
    ),
  ),
);

标签: flutter

解决方案


你可以使用这个例子。如果您想要用户列表而不是使用 SliverList 代替 SliverFillRemaining;

 class HeadState extends State<Head> {
      @override
      Widget build(BuildContext context) {
        var screenHeight = MediaQuery.of(context).size.height;
        var screenWidth = MediaQuery.of(context).size.width;

        return Scaffold(
          bottomNavigationBar: BottomNavigationBar(items: []),
          body: CustomScrollView(
            slivers: <Widget>[
              SliverAppBar(
                expandedHeight: screenHeight / 4,
                flexibleSpace: Container(
                  color: Colors.red,
                ),
              ),
              SliverFillRemaining(
                child: Container(
                  height: screenHeight - screenHeight / 4,
                  color: Colors.blue,
                ),
              )
            ],
          ),
        );
      }
    }

推荐阅读