initState method

  1. @override
void initState()
override

Reads the initial value from the first owner, resets to null when owners disagree, and detects the read-only flag across all owners.

Implementation

@override
void initState() {
  super.initState();

  int? value;
  if (widget.owners.isNotEmpty) {
    var property = widget.owners[0].getProperty(widget.propertyName);
    if (property != null) {
      value = property.getValue(widget.owners[0]);
    }
    for (int a = 1; a < widget.owners.length; a++) {
      var obj = widget.owners[a];
      var property = obj.getProperty(widget.propertyName);
      if (property == null) {
        value = null;
      } else if (property.getValue(obj) != value) {
        value = null;
      }
    }
  }

  for (var owner in widget.owners) {
    var property = owner.getProperty(widget.propertyName);
    if (property != null && property.readOnly) {
      readOnlyProperty = true;
      break;
    }
  }

  ted = TextEditingController(text: value != null ? value.toString() : '');
}