【发布时间】:2021-05-10 14:05:22
【问题描述】:
我们有:
final Widget? body;
稍后在代码中:
final content = Column(
children: [
...items,
if (body != null) body!
],
);
为什么我必须在正文后添加! 符号?
没有!我收到:
元素类型'Widget?'不能分配给列表类型“Widget”。
在 pubspec.yaml 中
environment:
sdk: '>=2.12.0-0 <3.0.0'
【问题讨论】: