build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Builds either a Slider.adaptive or a TextField depending on whether clamp is set.

Implementation

@override
Widget build(BuildContext context) {
  if (clamp != null) {
    double min = clamp!.$1;
    double max = clamp!.$2;
    //double value = initialValue;
    /*if (value < min) {
      value = min;
      widget.property.setValue!(widget.owner, value, widget.customData);
    }
    if (value > max) {
      value = max;
      widget.property.setValue!(widget.owner, value, widget.customData);
    }*/
    return Slider.adaptive(
      value: initialValue ?? 0.0,
      onChanged: (value) {
        var property = widget.owners[0].getProperty(widget.propertyName);
        property?.setValue!(widget.owners[0], value, widget.customData);
        initialValue = value;
        if (widget.onUpdateProperty != null) {
          widget.onUpdateProperty!(value);
        }
        if (mounted) {
          setState(() {});
        }
      },
      //label: '${widget.property.getValue(widget.owner)}',
      min: min,
      max: max,
    );
  } else {
    return TextField(
      controller: ted,
      readOnly: readOnlyProperty,
      decoration: InputDecoration(isDense: true),
      onChanged: (value) {
        if (!readOnlyProperty) {
          double? number = double.tryParse(value);
          if (number != null || isNullable) {
            for (var owner in widget.owners) {
              var property =
                  owner.getProperty(widget.propertyName)
                      as InspectableProperty<double>?;
              if (property != null && property.setValue != null) {
                property.setValue!(owner, number, null);
              }
            }
            if (widget.onUpdateProperty != null) {
              widget.onUpdateProperty!(value);
            }
          }
        }
      },
    );
  }
}