product method

T product({
  1. T? identity,
})

Product of all elements. Returns identity (default 1) if empty.

Implementation

T product({T? identity}) {
  if (isEmpty) return (identity ?? 1) as T;
  return reduce((a, b) => (a * b) as T);
}