IconComponent constructor

IconComponent({
  1. IconData? icon,
  2. double iconSize = 64,
  3. Paint? paint,
  4. Vector2? position,
  5. Vector2? size,
  6. Vector2? scale,
  7. double? angle,
  8. double nativeAngle = 0,
  9. Anchor? anchor,
  10. Iterable<Component>? children,
  11. int? priority,
  12. ComponentKey? key,
})

Creates an IconComponent that renders icon as a Flame component.

  • icon: The IconData to render (e.g., Icons.star).
  • iconSize: The resolution at which to rasterize the icon (default 64).
  • paint: Optional paint for rendering effects.
  • size: The display size of the component. Defaults to Vector2.all(iconSize) if not specified.

Implementation

IconComponent({
  IconData? icon,
  double iconSize = 64,
  Paint? paint,
  super.position,
  Vector2? size,
  super.scale,
  super.angle,
  super.nativeAngle,
  super.anchor,
  super.children,
  super.priority,
  super.key,
}) : _icon = icon,
     _iconSize = iconSize,
     super(size: size ?? Vector2.all(iconSize)) {
  if (paint != null) {
    this.paint = paint;
  }
  _dstRect = this.size.toRect();
  this.size.addListener(_updateDstRect);
}