AlignComponent constructor

AlignComponent({
  1. PositionComponent? child,
  2. Anchor alignment = Anchor.topLeft,
  3. double? widthFactor,
  4. double? heightFactor,
  5. bool keepChildAnchor = false,
})

Creates a component that keeps its child positioned according to the alignment within this component's bounding box.

More precisely, the child will be placed at alignment relative position within the current component's bounding box. The child's anchor will also be set to the alignment, unless keepChildAnchor parameter is true.

Implementation

AlignComponent({
  PositionComponent? child,
  Anchor alignment = Anchor.topLeft,
  this.widthFactor,
  this.heightFactor,
  this.keepChildAnchor = false,
}) {
  this.alignment = alignment;
  this.child = child;
}