flagCountAccumulator function

int flagCountAccumulator({
  1. required bool value,
  2. int? previous,
})

An Accumulator for flag arguments that counts the number of times the argument was true, minus the number of times the argument was false. May return a value less than 0 if more false values are given than true values.

Implementation

int flagCountAccumulator({required bool value, int? previous}) =>
    (previous ?? 0) + (value ? 1 : -1);