arrayArgMax function Null safety

int arrayArgMax(
  1. Array a
)

Return the index of the first greater element of the array

Examples

var n = Array([1, 2, 3]);

print(arrayArgMax(n));

/* expected output:
2
*/

Implementation

int arrayArgMax(Array a) {
  var el = a.reduce(max);
  return a.indexOf(el);
}