setItems method

void setItems(
  1. List<ChartPieItem> items
)

Implementation

void setItems(List<ChartPieItem> items) {
  List<ChartPieItem> result = [];
  var defaultColorIndex = 0;

  for (var item in items) {
    result.add(ChartPieItem(
      value: item.value,
      color: item.color ?? ChartPieItem.colors[defaultColorIndex],
      title: item.title,
    ));
    defaultColorIndex++;
    if (defaultColorIndex >= ChartPieItem.colors.length) {
      defaultColorIndex = 0;
    }
  }

  setState(() {
    _items = result;
  });
}