Flutter中使用Column中白屏问题

日常开发中Column出现白屏

记录平时Flutter项目开发中的一些问题


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBarLeftTitle(
        title: '选择数据',
        rightWidget: ButtonCommon(
          margin: EdgeInsets.symmetric(horizontal: 10.0),
          text: '返回上一级',
          fontSize: 12.0,
          width: 80,
          height: 30,
          color: ColorHelper.linkBlue,
          circular: 5.0,
          onTap: () {
          }
        ),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            Expanded(
              child:  CupertinoScrollbar(
                child: ListView(
                  children: [
                    GestureDetector(
                      onTap: () {},
                      child: Column(
                        mainAxisSize: MainAxisSize.min,
                        children: <Widget>[
                          Container(
                            color: Colors.white,
                            height: 46,
                            padding: EdgeInsets.symmetric(horizontal: 15),
                            child: Row(
                              children: <Widget>[
                                TextCommon('测试', size: 14, color: Colors.black),
                                Spacer(),
                                TextCommon('测试', size: 14, color: Color(0xFFCCCCCC))
                              ],
                            ),
                          ),
                          Padding(
                            padding: EdgeInsets.symmetric(horizontal: 15),
                            child: DividerHorizontal(),
                          ),
                        ],
                      ),
                    )
                  ]
                )
              )
            )
          ],
        )
      ),
    );
  }

结果运行报错,关键错误提示如下

======== Exception caught by rendering library ===================================================== The following assertion was thrown during paint(): RenderBox was not laid out:
RenderRepaintBoundary#6c4b0 relayoutBoundary=up1 NEEDS-PAINT
‘package:flutter/src/rendering/box.dart’: Failed assertion: line 1785
pos 12: ‘hasSize’

Either the assertion indicates an error in the framework itself, or we
should provide substantially more information in this error message to
help you determine and fix the underlying cause. In either case,
please report this assertion by filing a bug on GitHub

其实就是外面的SingleChildScrollView与里面的Column的ListView出现了冲突,所以要想解决这个问题,去掉外面的SingleChildScrollView即可

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值