第二次提交
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class EmergencyOverlay extends StatefulWidget {
|
||||
const EmergencyOverlay({super.key});
|
||||
|
||||
@override
|
||||
State<EmergencyOverlay> createState() => _EmergencyOverlayState();
|
||||
}
|
||||
|
||||
class _EmergencyOverlayState extends State<EmergencyOverlay>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late AnimationController _controller;
|
||||
late Animation<double> _opacityAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// 设置动画循环时间,例如 600ms 闪烁一次
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 600),
|
||||
)..repeat(reverse: true); // 反转运行实现呼吸效果
|
||||
|
||||
_opacityAnimation = Tween<double>(
|
||||
begin: 0.0,
|
||||
end: 0.5,
|
||||
).animate(CurvedAnimation(parent: _controller, curve: Curves.easeInOut));
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedBuilder(
|
||||
animation: _opacityAnimation,
|
||||
builder: (context, child) {
|
||||
return IgnorePointer(
|
||||
// 极其重要:确保光晕不遮挡下方的点击事件
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
// 使用径向渐变,让四周红,中间透明
|
||||
border: Border.all(
|
||||
color: Colors.red.withOpacity(_opacityAnimation.value),
|
||||
width: 20, // 边框宽度决定了红边的厚度
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.red.withOpacity(_opacityAnimation.value),
|
||||
blurRadius: 40,
|
||||
spreadRadius: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user