node function

GzBaseNode node(
  1. String id, {
  2. List<GzBaseNode>? children,
  3. String? label,
  4. String? color,
  5. String? fontColor,
  6. String? shape,
})

A shorthand util that constructs either a GzChunk node or a GzNode based on whether or not children are provided.

Implementation

GzBaseNode node(
  String id, {
  List<GzBaseNode>? children,
  String? label,
  String? color,
  String? fontColor,
  String? shape,
}) => switch (children) {
  final List<GzBaseNode> ls => GzChunk(
    id: id,
    children: ls,
    label: label,
    color: color,
    fontColor: fontColor,
    shape: shape,
  ),
  null => GzNode(
    id: id,
    label: label,
    color: color,
    fontColor: fontColor,
    shape: shape,
  ),
};