formatTypeTooltip function
Build a multi-line indented string showing struct/array fields with values.
Used for schematic hover tooltips.
Implementation
String formatTypeTooltip(
Map<String, dynamic>? logicType, {
String? parentBinaryValue,
String? signalName,
int maxDepth = 6,
}) {
if (logicType == null) {
return '';
}
final nodes = expandLogicType(
logicType,
parentBinaryValue: parentBinaryValue,
);
if (nodes.isEmpty) {
return '';
}
final buf = StringBuffer();
final typeName = logicType['typeName'] as String?;
if (signalName != null) {
buf.write(signalName);
if (typeName != null) {
buf.write(' ($typeName)');
}
buf.writeln();
} else if (typeName != null) {
buf.writeln(typeName);
}
for (final node in nodes) {
_formatNode(buf, node, indent: 1, maxDepth: maxDepth);
}
return buf.toString().trimRight();
}