vec2<C extends Component> static method

ComponentField<C> vec2<C extends Component>(
  1. String name, {
  2. required Vector2 defaultValue(),
  3. Vector2 get(
    1. C component
    )?,
  4. void set(
    1. C component,
    2. Vector2 value
    )?,
  5. String? doc,
  6. String? group,
  7. List<PropertyConstraint<Object>> constraints = const [],
  8. List<String> formerNames = const [],
  9. bool transient = false,
})

A Vector2 property.

Implementation

static ComponentField<C> vec2<C extends Component>(
  String name, {
  required Vector2 Function() defaultValue,
  Vector2 Function(C component)? get,
  void Function(C component, Vector2 value)? set,
  String? doc,
  String? group,
  List<PropertyConstraint<Object>> constraints = const [],
  List<String> formerNames = const [],
  bool transient = false,
}) => ComponentField(
  ComponentPropertyDef(
    name,
    ComponentPropertyKind.vec2,
    defaultValue: Vec2Value(defaultValue()),
    doc: doc,
    group: group,
    constraints: constraints,
    formerNames: formerNames,
    transient: transient,
  ),
  read: get == null ? null : (c, _) => Vec2Value(get(c).clone()),
  write: set == null
      ? null
      : (c, v, _) {
          if (v is Vec2Value) set(c, v.value.clone());
        },
);