BreathBox class

呼吸灯动画组件,用于为指定的子组件添加呼吸缩放发光效果。

该组件通过循环缩放及透明度动画,模拟“呼吸”特效,可自定义最小/最大缩放、发光色、大小,并在动画过程中获取缩放比例等信息。

参数说明

使用示例

BreathBox(
  minScale: 0.8,
  maxScale: 1.3,
  size: 150,
  glowColor: Colors.blue,
  onBreathing: (scale) {
    print('当前缩放比例: $scale');
  },
  onScaleUp: () {
    print('放大中');
  },
  onScaleDown: () {
    print('缩小中');
  },
  child: Image.asset('assets/images/icon.png'),
)

返回

返回一个带有呼吸特效的Widget。

Inheritance

Constructors

BreathBox({Key? key, required Widget child, double minScale = 0.6, double maxScale = 1.6, double size = 180, Color glowColor = Colors.lightBlue, VoidCallback? onScaleUp, VoidCallback? onScaleDown, void onBreathing(double scale)?})
构造方法
const

Properties

child Widget
需要添加呼吸效果的子组件
final
glowColor Color
发光背景颜色
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxScale double
最大缩放比例
final
minScale double
最小缩放比例
final
onBreathing → void Function(double scale)?
呼吸过程缩放比例变化时的回调
final
onScaleDown VoidCallback?
缩小动画方向回调
final
onScaleUp VoidCallback?
放大动画方向回调
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size double
组件像素大小
final

Methods

build(BuildContext context) Widget
构建呼吸灯动画组件。
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited