【问题标题】:SingleChildScrollView still overflowingSingleChildScrollView 仍然溢出
【发布时间】:2022-11-14 00:30:20
【问题描述】:

我在 Sized 框中有一个 SingleChildScrollView。我认为这会使我的页面可滚动,但事实并非如此。我运行它时得到这个

我有代码

Container(
    width: double.infinity,
    alignment: Alignment.centerLeft,
    child: Column(
        children: [
            const SizedBox(
                width: double.infinity,
                child: some text
            ),
            const SizedBox(height: 10),
            SizedBox(
                    width: double.infinity,
                    child: SingleChildScrollView(
                        child: Column(
                            children: items
                                    .map((e) => ListTile(
                                                most recent items
                                            ))
                                    .toList(),
                        ),
                    )),
        ],
    ))

【问题讨论】:

    标签: flutter dart flutter-layout


    【解决方案1】:

    把它包起来

    Expanded(
    child :SizedBox(
    child :...
    )
    )
    

    或者

    SizedBox.expand(
    
    )
    

    或给定尺寸的盒子屏幕尺寸

    var screenWidth = MediaQuery.of(context).size.width
    var screenHieght = MediaQuery.of(context).size.height
    

    大小盒( 宽度:屏幕宽度, 高度:屏幕高度 孩子:你的孩子在这里, )

    【讨论】:

      【解决方案2】:

      你需要用Expanded 包裹你的SizedBox,所以SingleChildScrollView 在column 中可用height,像这样:

      Expanded(
        child: SizedBox(
            width: double.infinity,
            child: SingleChildScrollView(
              ...
            ),
        ),
      )
      

      【讨论】:

        猜你喜欢
        • 2020-12-29
        • 2021-06-18
        • 1970-01-01
        • 1970-01-01
        • 2013-08-31
        • 1970-01-01
        • 1970-01-01
        • 2022-01-01
        • 2021-09-05
        相关资源
        最近更新 更多