build method
Builds the inspector table.
Computes the intersection of properties across all Inspector.objects, then renders one TableRow per common property. The keys cache is cleared whenever the objects list changes so editors are recreated with fresh state.
Implementation
@override
Widget build(BuildContext context) {
List<TableRow> fields = [];
Set<(String, Type)> commonProperties = {};
List<Inspectable> owners = [];
if (!ListEquality().equals(widget.objects, objects)) {
keys.clear();
}
objects = widget.objects;
for (var obj in widget.objects) {
var properties = getObjectPropertySet(obj);
if (commonProperties.isEmpty) {
commonProperties = properties;
owners = [obj];
} else {
commonProperties = commonProperties.intersection(properties);
owners.add(obj);
}
}
for (var property in commonProperties) {
fields.add(populateProperty(owners, property.$1, 1));
}
return SingleChildScrollView(
child: Table(
border: TableBorder.all(color: Colors.grey.shade500),
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
columnWidths: const {0: IntrinsicColumnWidth(), 1: FlexColumnWidth()},
children: fields,
),
);
}