Skip to content

Commit

Permalink
fix: Move errorBuilder and loadingBuilder to constructors (#2526)
Browse files Browse the repository at this point in the history
To make it consistent with the other constructors, all builders should be settable from the default constructor.
  • Loading branch information
spydon committed May 2, 2023
1 parent 472356d commit 55ec0bc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions packages/flame/lib/src/widgets/animation_widget.dart
Expand Up @@ -12,19 +12,19 @@ export '../sprite_animation.dart';

/// A [StatelessWidget] that renders a [SpriteAnimation]
class SpriteAnimationWidget extends StatelessWidget {
/// The positioning [Anchor]
/// The positioning [Anchor].
final Anchor anchor;

/// Should the animation be playing or not
/// Whether the animation should be playing or not.
final bool playing;

final FutureOr<SpriteAnimation> _animationFuture;
final SpriteAnimationTicker? _animationTicker;

/// A builder function that is called if the loading fails
/// A builder function that is called if the loading fails.
final WidgetBuilder? errorBuilder;

/// A builder function that is called while the loading is on the way
/// A builder function that is called while the loading is on the way.
final WidgetBuilder? loadingBuilder;

/// A callback that is called when the animation completes.
Expand All @@ -35,12 +35,12 @@ class SpriteAnimationWidget extends StatelessWidget {
required SpriteAnimationTicker animationTicker,
this.playing = true,
this.anchor = Anchor.topLeft,
this.errorBuilder,
this.loadingBuilder,
this.onComplete,
super.key,
}) : _animationFuture = animation,
_animationTicker = animationTicker,
errorBuilder = null,
loadingBuilder = null,
onComplete = null;
_animationTicker = animationTicker;

/// Loads image from the asset [path] and renders it as a widget.
///
Expand Down
8 changes: 4 additions & 4 deletions packages/flame/lib/src/widgets/sprite_button.dart
Expand Up @@ -51,13 +51,13 @@ class SpriteButton extends StatelessWidget {
this.srcSize,
this.pressedSrcPosition,
this.pressedSrcSize,
this.errorBuilder,
this.loadingBuilder,
super.key,
}) : _buttonsFuture = [
}) : _buttonsFuture = [
sprite,
pressedSprite,
],
errorBuilder = null,
loadingBuilder = null;
];

SpriteButton.future({
required Future<Sprite> sprite,
Expand Down
6 changes: 3 additions & 3 deletions packages/flame/lib/src/widgets/sprite_widget.dart
Expand Up @@ -39,10 +39,10 @@ class SpriteWidget extends StatelessWidget {
this.angle = 0,
this.srcPosition,
this.srcSize,
this.errorBuilder,
this.loadingBuilder,
super.key,
}) : _spriteFuture = sprite,
errorBuilder = null,
loadingBuilder = null;
}) : _spriteFuture = sprite;

/// Load the image from the asset [path] and renders it as a widget.
///
Expand Down

0 comments on commit 55ec0bc

Please sign in to comment.