build method

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

Builds a collapsed TextField that writes string values back to all owners on every keystroke.

When _items are available the method currently returns an empty Container (dropdown mode is reserved for a future release).

Implementation

@override
Widget build(BuildContext context) {
  if (_items != null && _items!.isNotEmpty) {
    return Container();
    /*return DropdownButton<String>(
      isExpanded: true,
      isDense: true,
      value: widget.property.getValue(widget.owner),
      items: _items,
      onChanged: (value) {
        if (value != null && !widget.property.readOnly && widget.property.setValue != null) {
          widget.property.setValue!(widget.owner, value, widget.customData);
          setState(() {});
        }
      },
    );*/
  } else {
    return TextField(
      controller: ted,
      readOnly: readOnlyProperty,
      decoration: const InputDecoration.collapsed(hintText: ''),
      onChanged: (value) {
        String? finalValue = value;
        if (value.isEmpty && nullableProperty) {
          finalValue = null;
        }
        if (!readOnlyProperty) {
          for (var owner in widget.owners) {
            var property = owner.getProperty(widget.propertyName);
            if (property != null && property.setValue != null) {
              property.setValue!(owner, finalValue, null);
            }
          }
          if (widget.onUpdateProperty != null) {
            widget.onUpdateProperty!(finalValue);
          }
          if (mounted) {
            setState(() {});
          }
        }
      },
    );
  }
}