int argmax(List<num> array) { return array .reduceIndexed((index, previous, element) => array[previous.toInt()] < element ? index : previous) .toInt(); }