flutter错误之 The method '>' was called on null

如下方的报错,一般是ListView搭配Column或者Row出错了,看我下面的错误是Column


════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderFlex#c1bcd relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1687 pos 12: 'hasSize'
The relevant error-causing widget was
    Scaffold 
lib\pages\Cart.dart:19
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════
The method '>' was called on null.
Receiver: null
Tried calling: >(1e-10)
The relevant error-causing widget was
    Column 
lib\pages\Cart.dart:21
════════════════════════════════════════════════════════════════════════════════
Reloaded 2 of 568 libraries in 193ms.

在这里插入图片描述
还有一种错误是Row:
在这里插入图片描述
解决方法:把包含在Column下的ListView容器放在Expand就可以了,然后 在ListView中加入shrinkWrap: true就可以了,Row 同理

new Column(
children: <Widget>[
 Expanded(
       child: new Container(
          child: new ListView(
            padding: EdgeInsets.only(top: 0),
            shrinkWrap: true,
            )))
]
)

成功解决:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值