string<C extends Component> static method
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);
},
);