string<C extends Component> static method

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

A free-form string property.

Implementation

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