integer<C extends Component> static method
An integer property.
Implementation
static ComponentField<C> integer<C extends Component>(
String name, {
required int defaultValue,
int Function(C component)? get,
void Function(C component, int value)? set,
String? doc,
String? group,
List<PropertyConstraint<int>> constraints = const [],
List<String> formerNames = const [],
bool transient = false,
}) => ComponentField(
ComponentPropertyDef(
name,
ComponentPropertyKind.integer,
defaultValue: IntValue(defaultValue),
doc: doc,
group: group,
constraints: constraints,
formerNames: formerNames,
transient: transient,
),
read: get == null ? null : (c, _) => IntValue(get(c)),
// Authored values apply verbatim; constraints describe the editing UI
// (the editor clamps on edit) and must not mutate legal documents on a
// load/save round trip.
write: set == null
? null
: (c, v, _) {
if (v is IntValue) set(c, v.value);
},
);