number<C extends Component> static method
A floating-point property.
Implementation
static ComponentField<C> number<C extends Component>(
String name, {
required double defaultValue,
double Function(C component)? get,
void Function(C component, double value)? set,
String? doc,
String? group,
List<PropertyConstraint<num>> constraints = const [],
List<String> formerNames = const [],
bool transient = false,
}) => ComponentField(
ComponentPropertyDef(
name,
ComponentPropertyKind.number,
defaultValue: DoubleValue(defaultValue),
doc: doc,
group: group,
constraints: constraints,
formerNames: formerNames,
transient: transient,
),
read: get == null ? null : (c, _) => DoubleValue(get(c)),
write: set == null
? null
: (c, v, _) {
final number = switch (v) {
DoubleValue(:final value) => value,
IntValue(:final value) => value.toDouble(),
_ => null,
};
if (number != null) set(c, number);
},
);