number<S> static method

DiagramProperty<S, double> number<S>(
  1. String key, {
  2. required String label,
  3. required double read(
    1. S subject
    ),
  4. String? verb,
  5. DiagramPropertyArgs<S, double>? args,
  6. S update(
    1. S subject,
    2. double value
    )?,
  7. DiagramPropertyGroup group = DiagramPropertyGroup.general,
  8. double min = 0,
  9. double max = 1000000,
  10. double step = 1,
  11. String unit = '',
  12. int? precision,
  13. DiagramNumberStyle style = DiagramNumberStyle.stepper,
  14. (double, double) bounds(
    1. S subject
    )?,
  15. bool visible(
    1. S subject
    )?,
  16. bool enabled(
    1. S subject
    )?,
  17. String? check(
    1. double value
    )?,
  18. String editLabel(
    1. double value
    )?,
})

A number between min and max, changed in steps. precision sets the displayed decimal places; by default it follows step. bounds narrows the range for a subject.

Implementation

static DiagramProperty<S, double> number<S>(
  String key, {
  required String label,
  required double Function(S subject) read,
  String? verb,
  DiagramPropertyArgs<S, double>? args,
  S Function(S subject, double value)? update,
  DiagramPropertyGroup group = DiagramPropertyGroup.general,
  double min = 0,
  double max = 1000000,
  double step = 1,
  String unit = '',
  int? precision,
  DiagramNumberStyle style = DiagramNumberStyle.stepper,
  (double min, double max) Function(S subject)? bounds,
  bool Function(S subject)? visible,
  bool Function(S subject)? enabled,
  String? Function(double value)? check,
  String Function(double value)? editLabel,
}) {
  if (!min.isFinite || !max.isFinite || min > max || step <= 0) {
    throw ArgumentError('A number needs finite ordered bounds and a step.');
  }
  return DiagramProperty._(
    key,
    label: label,
    presentation: DiagramNumberPresentation._(
      min: min,
      max: max,
      step: step,
      unit: unit,
      precision: precision,
      style: style,
      bounds: bounds == null ? null : (subject) => bounds(subject as S),
    ),
    read: read,
    verb: verb,
    args: args,
    update: update,
    group: group,
    visible: visible,
    enabled: enabled,
    check: check,
    editLabel: editLabel,
  );
}