TxShimmer class
小部件树上呈现微光效果的组件。 child 定义了闪光效果混合的区域。 您可以从您喜欢的任何 Widget 构建 child, 但为了获得准确的预期效果并获得更好的渲染性能,请注意一些注意事项: 使用静态 Widget(它是 StatelessWidget 的一个实例)。 Widget 应该是纯色元素。您在这些 Widget 上设置的每种颜色都将被
gradient 的颜色覆盖。微光效果只影响 child 的不透明区域,透明区域仍然保持透明。
period 控制微光效果的速度。默认值为 1500 毫秒。
direction 控制微光效果的方向。默认值为 ShimmerDirection.ltr。
gradient 控制微光效果的颜色。
loop 动画循环次数,设置为 0
使动画永远运行。
enabled 控制是否激活微光效果。设置为 false 时动画暂停
专业提示:child 应由基本简单的 Widget 组成, 例如 Container、Row 和 Column,以避免副作用。
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- TxShimmer
- Annotations
Constructors
- TxShimmer.new({required Widget child, required Gradient gradient, Key? key, ShimmerDirection direction = ShimmerDirection.ltr, Duration period = const Duration(milliseconds: 1500), int loop = 0, bool enabled = true})
-
创建一个TxShimmer
const
- TxShimmer.fromColors({required Widget child, required Color baseColor, required Color highlightColor, Key? key, Duration period = const Duration(milliseconds: 1500), ShimmerDirection direction = ShimmerDirection.ltr, int loop = 0, bool enabled = true})
-
一个方便的构造函数提供了一种简单方便的方法来创建一个 TxShimmer,
其中 gradient 是由
baseColor
和highlightColor
组成的 LinearGradient。
Properties
- child → Widget
-
final
- direction → ShimmerDirection
-
final
- enabled → bool
-
final
- gradient → Gradient
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loop → int
-
final
- period → Duration
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< StatefulWidget> -
Creates the mutable state for this widget at a given location in the tree.
override
-
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.
override
-
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