From ce351ad0f60a155ada45280624ff67e1a2ac1b2d Mon Sep 17 00:00:00 2001 From: "minh.tran" Date: Sun, 6 Jun 2021 19:06:49 +0700 Subject: [PATCH] Add placeHolder to RiveAnimation --- lib/src/widgets/rive_animation.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/widgets/rive_animation.dart b/lib/src/widgets/rive_animation.dart index ea86c28..f860e5f 100644 --- a/lib/src/widgets/rive_animation.dart +++ b/lib/src/widgets/rive_animation.dart @@ -21,6 +21,8 @@ class RiveAnimation extends StatefulWidget { final String? animation; final BoxFit? fit; final Alignment? alignment; + /// Widget displayed while the rive is loading. + final Widget? placeHolder; /// Creates a new RiveAnimation from an asset bundle const RiveAnimation.asset( @@ -29,6 +31,7 @@ class RiveAnimation extends StatefulWidget { this.animation, this.fit, this.alignment, + this.placeHolder, }) : src = _Source.asset; const RiveAnimation.network( @@ -37,6 +40,7 @@ class RiveAnimation extends StatefulWidget { this.animation, this.fit, this.alignment, + this.placeHolder, }) : src = _Source.network; @override @@ -129,5 +133,5 @@ class _RiveAnimationState extends State { fit: widget.fit, alignment: widget.alignment, ) - : const SizedBox(); + : widget.placeHolder ?? const SizedBox(); }