final RxDouble blurStrength = 0.0.obs;
final ScrollController controller = ScrollController();
@override
void initState() {
super.initState();
controller.addListener(() {
var offset = controller.offset;
if (offset > 450.w) {
bShowAppbarTitle.value = true;
} else {
bShowAppbarTitle.value = false;
}
if (offset > 1100.w) {
bShowCover = false;
blurStrength.value =10;
} else {
bShowCover = true;
blurStrength.value =
(controller.offset / 1100.w)*10; // 根据偏移量计算模糊强度
}
bShowClip.value = offset > 450.w;
if (bLastShowCover != bShowCover) {
logic.update(["background"]);
bLastShowCover = bShowCover;
}
});
}
Widget _buildCover() {
return Obx(() {
return Stack(
children: [
// 原始图片
LoadImage(
logic.material?.appList.firstOrNull?.picList.firstOrNull?.icon ??
"",
width: 1080.w,
height: 1100.w,
),
// 动态模糊效果
Positioned.fill(
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: blurStrength.value, sigmaY: blurStrength.value),
child: Container(
color: Colors.black.withOpacity(0.3),
),
),
),
],
);
});
}
网友评论