当剪辑值仅在剪辑值显示内更改时,我必须将图像设置为模糊,而不模糊显示模糊的其他部分。
child: Container(
height: height,
width: width,
decoration: BoxDecoration(
color: Colors.transparent,
border: Border.all(
width: 2,
color: _isSelected && _showAlternateContainer
? Colors.black
: Colors.red,
),
),
child: ClipRect(
clipBehavior: Clip.hardEdge,
clipper: MyCustomClipper(
clipLeft,
clipTop,
_showAlternateContainer ? width : clipWidth,
_showAlternateContainer ? height : clipHeight),
child: Image.asset(
image,
width: width,
height: height,
fit: BoxFit.fill,
),
),
),
像这样添加仅剪辑区域显示其他区域显示模糊。
child: Container(
height: height,
width: width,
decoration: BoxDecoration(
color: Colors.transparent,
border: Border.all(
width: 2,
color: _isSelected && _showAlternateContainer
? Colors.black
: Colors.red,
),
),
child: Stack(
children: [
// Blurred image as the background
if(_showAlternateContainer)
ImageFiltered(
imageFilter: ui.ImageFilter.blur(sigmaX: 3, sigmaY: 3),
child: Image.asset(
image,
width: width,
height: height,
fit: BoxFit.fill,
),
),
// Clipped area with clear image
ClipRect(
clipBehavior: Clip.hardEdge,
clipper: MyCustomClipper(
clipLeft,
clipTop,
clipWidth,
clipHeight,
),
child: Image.asset(
image,
width: width,
height: height,
fit: BoxFit.fill,
),
),
],
)
),