SpriteWidget constructor

const SpriteWidget(
  1. NodeWithSize rootNode, {
  2. SpriteBoxTransformMode transformMode = SpriteBoxTransformMode.letterbox,
  3. Key? key,
})

Creates a new sprite widget with rootNode as its content.

The widget will setup the coordinate space for the sprite node tree using the size of the rootNode in combination with the supplied transformMode. By default the letterbox transform mode is used. See SpriteBoxTransformMode for more details on the different modes.

The most common way to setup the sprite node graph is to subclass NodeWithSize and pass it to the sprite widget. In the custom subclass it's possible to build the node graph, do animations and handle user events.

var mySpriteTree = MyCustomNodeWithSize();
var mySpriteWidget =
  SpriteWidget(mySpriteTree, SpriteBoxTransformMode.fixedHeight);

Implementation

const SpriteWidget(
  this.rootNode, {
  this.transformMode = SpriteBoxTransformMode.letterbox,
  Key? key,
}) : super(key: key);