Flutter web:需要一个“SkDeletable”类型的值,但得到一个“Null”类型的值
Posted
技术标签:
【中文标题】Flutter web:需要一个“SkDeletable”类型的值,但得到一个“Null”类型的值【英文标题】:Flutter web: Expected a value of type 'SkDeletable', but got one of type 'Null' 【发布时间】:2021-07-13 16:48:22 【问题描述】:在 Flutter web 中遇到此错误:Expected a value of type 'SkDeletable', but got one of type 'Null'
在尝试构建卡片时。
它在release mode
中运行良好,但在debug mode
中运行良好。有人知道这是从哪里来的吗?错误日志并没有说明太多,除了导致它的小部件的位置,即CustomCard
这是我的代码:
CustomCard(
cardWidth: _cardWidth,
cardHeight: _cardHeight,
serviceIcon: servicesBackgrounds[3],
serviceTitle: servicesTitles[3],
serviceDescription: servicesDescriptions[3],
),
//--------------------------------------------- --------------------------------------------------//
final double _height = MediaQuery.of(context).size.height;
final double _width = MediaQuery.of(context).size.width;
Container(
width: widget.cardWidth,
height: widget.cardHeight,
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
child: Card(
semanticContainer: true,
clipBehavior: Clip.antiAliasWithSaveLayer,
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
elevation: 2,
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: ExactAssetImage(widget.serviceIcon),
fit: BoxFit.cover),
color: darkBlue,
borderRadius: BorderRadius.circular(10),
boxShadow: isHover
? [
BoxShadow(
color: crimson,
blurRadius: 24.0,
offset: Offset(5.0, 15.0))
]
: []),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 0, sigmaY: 0),
child: Container(
decoration: BoxDecoration(color: darkBlue.withOpacity(0.8)),
//alignment: Alignment.center,
child: Stack(
children: [
Positioned(
top: _height * 0.02,
right: _width * 0.1,
left: _width * 0.1,
child: Text(widget.serviceTitle,
textAlign: TextAlign.center,
style: brandTextStyle(white, 25)),
),
Positioned(
right: _width * 0.1,
left: _width * 0.1,
bottom: _height * 0.1,
child: Text(widget.serviceDescription,
textAlign: TextAlign.center,
style: typerTextStyle(white, 14)),
)
],
),
),
),
),
),
),
【问题讨论】:
【参考方案1】:您应该使用:
filter: ImageFilter.blur(sigmaX: 0.001, sigmaY: 0.001),
代替:
filter: ImageFilter.blur(sigmaX: 0, sigmaY: 0),
【讨论】:
以上是关于Flutter web:需要一个“SkDeletable”类型的值,但得到一个“Null”类型的值的主要内容,如果未能解决你的问题,请参考以下文章