changeBlocks method

({int added, int removed}) changeBlocks()

How many of the changeBarSize squares go to additions and to deletions. Each kind of change that happened gets at least one. Without changes, both are 0.

Implementation

({int added, int removed}) changeBlocks() {
  final total = additions + deletions;
  if (total == 0) return (added: 0, removed: 0);
  final added = (changeBarSize * additions / total).round().clamp(
    additions > 0 ? 1 : 0,
    deletions > 0 ? changeBarSize - 1 : changeBarSize,
  );
  return (added: added, removed: changeBarSize - added);
}