percent method

double percent(
  1. double total
)

Percentage of total that this segment represents.

Implementation

double percent(double total) => total > 0 ? (value / total) * 100 : 0;