legendEllipsisBuilder property

EllipsisBuilder? legendEllipsisBuilder
final

A builder of an ellipsis LegendItem.

If the number of lines in the legend is limited, i.e., style.maxLines is not null, and if the legend failed to align some items within the given line limit, the overflowing items are not shown and instead an item that is created by ellipsisBuilder (called an ellipsis) is displayed as the last item in the legend.

If style.maxLines is not null, this property must not also be null.

Example:

List<Segment> segments;

SegmentedBarLegend(
  legendStyle: const SegmentedBarLegendStyle(maxLines: 2),
  ellipsisBuilder: (truncatedItemCount) {
    final value = segments
        .skip(segments.length - truncatedItemCount)
        .fold(0, (accValue, segment) => accValue + segment.value);
    return LegendItem(
      segment: Segment(
        value: value,
        color: Colors.grey,
        label: const Text("Other"),
        formattedValue: Text("$value%"),
      ),
    );
  },
);

Implementation

final EllipsisBuilder? legendEllipsisBuilder;