mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-06-26 17:56:28 +08:00
Add placeHolder to RiveAnimation
This commit is contained in:
@ -21,6 +21,8 @@ class RiveAnimation extends StatefulWidget {
|
|||||||
final String? animation;
|
final String? animation;
|
||||||
final BoxFit? fit;
|
final BoxFit? fit;
|
||||||
final Alignment? alignment;
|
final Alignment? alignment;
|
||||||
|
/// Widget displayed while the rive is loading.
|
||||||
|
final Widget? placeHolder;
|
||||||
|
|
||||||
/// Creates a new RiveAnimation from an asset bundle
|
/// Creates a new RiveAnimation from an asset bundle
|
||||||
const RiveAnimation.asset(
|
const RiveAnimation.asset(
|
||||||
@ -29,6 +31,7 @@ class RiveAnimation extends StatefulWidget {
|
|||||||
this.animation,
|
this.animation,
|
||||||
this.fit,
|
this.fit,
|
||||||
this.alignment,
|
this.alignment,
|
||||||
|
this.placeHolder,
|
||||||
}) : src = _Source.asset;
|
}) : src = _Source.asset;
|
||||||
|
|
||||||
const RiveAnimation.network(
|
const RiveAnimation.network(
|
||||||
@ -37,6 +40,7 @@ class RiveAnimation extends StatefulWidget {
|
|||||||
this.animation,
|
this.animation,
|
||||||
this.fit,
|
this.fit,
|
||||||
this.alignment,
|
this.alignment,
|
||||||
|
this.placeHolder,
|
||||||
}) : src = _Source.network;
|
}) : src = _Source.network;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -129,5 +133,5 @@ class _RiveAnimationState extends State<RiveAnimation> {
|
|||||||
fit: widget.fit,
|
fit: widget.fit,
|
||||||
alignment: widget.alignment,
|
alignment: widget.alignment,
|
||||||
)
|
)
|
||||||
: const SizedBox();
|
: widget.placeHolder ?? const SizedBox();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user