You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SpriteWidget Class has two parameters, "srcPosition" and "srcSize", that are not used.
What do you expect?
I expect that this is either noted in the documentation or that the parameters are not requested in the constructor.
How can we reproduce this?
// The fields of the classfinalAnchor anchor;
finaldouble angle;
/// Holds the position of the sprite on the imagefinalVector2? srcPosition;
/// Holds the size of the sprite on the imagefinalVector2? srcSize;
finalWidgetBuilder? errorBuilder;
finalWidgetBuilder? loadingBuilder;
finalFutureOr<Sprite> _spriteFuture;
// The build method.// Here you can see the fields that are used.// srcPosition and srcSize are directed into the _spriteFuture, which we see at in the last code block.@overrideWidgetbuild(BuildContext context) {
returnBaseFutureBuilder<Sprite>(
future: _spriteFuture,
builder: (_, sprite) {
returnInternalSpriteWidget(
sprite: sprite,
anchor: anchor,
angle: angle,
);
},
errorBuilder: errorBuilder,
loadingBuilder: loadingBuilder,
);
}
constSpriteWidget({
requiredSprite sprite,
this.anchor =Anchor.topLeft,
this.angle =0,
this.srcPosition, // mentioned in the constructor, but never used inside the classthis.srcSize, // check the constructor below.this.errorBuilder,
this.loadingBuilder,
super.key,
}) : _spriteFuture = sprite;
/// Load the image from the asset [path] and renders it as a widget. /// /// It will use the [loadingBuilder] while the image from [path] is loading. /// To render without loading, or when you want to have a gapless playback /// when the [path] value changes, consider loading the image beforehand /// and direct pass it to the default constructor.SpriteWidget.asset({
requiredString path,
Images? images,
this.anchor =Anchor.topLeft,
this.angle =0,
this.srcPosition,
this.srcSize,
this.errorBuilder,
this.loadingBuilder,
super.key,
}) : _spriteFuture =Sprite.load(
path,
srcSize: srcSize,
srcPosition: srcPosition, // here, srcPosition and srcSize are directed into the _spriteFuture but never used in the class itself
images: images,
);
What steps should take to fix this?
Because the parameters are only used to be redirected into the Sprite.load() method in the SpriteWidget.asset() constructor, i would suggest that these fields should be removed from the SpriteWidget class.
The documentation of the constructor can therefore mention that these parameters should be used in the Sprite.load() method.
What happened?
The SpriteWidget Class has two parameters, "srcPosition" and "srcSize", that are not used.
What do you expect?
I expect that this is either noted in the documentation or that the parameters are not requested in the constructor.
How can we reproduce this?
What steps should take to fix this?
Because the parameters are only used to be redirected into the Sprite.load() method in the SpriteWidget.asset() constructor, i would suggest that these fields should be removed from the SpriteWidget class.
The documentation of the constructor can therefore mention that these parameters should be used in the Sprite.load() method.
Affected platforms
All
Other information
Link to the file: packages/flame/lib/src/widgets/sprite_widget.dart
Are you interested in working on a PR for this?
The text was updated successfully, but these errors were encountered: