このページはまだ翻訳されていないため、英語で表示されます。 翻訳に参加する

min

The smallest number in the pipeline — with FxTS's exact quirks on empty and NaN input.

num min(Iterable<num> iterable) Future<num> minAsync(FxAsyncIterable<num> iterable) num Fx<num>.min() // chain (sync) Future<num> FxAsync<num>.min() // chain (async)

Lecture

min is a terminal, numeric-only fold — internally it's fold(double.infinity, ..., iterable), comparing each element against a running minimum that starts at +infinity.

Two behaviors are worth memorizing, because they surprise people coming from a "safe" API and are ported faithfully from FxTS:

If you need "smallest, or null if empty" semantics instead, check result.isInfinite yourself, or reach for find / reduce with your own comparator.

Demo 1 · Basics, empty, and NaN

Demo 2 · Async

Try it yourself

Exercise: find the cheapest price among the products.

Related: max — the mirror image · sum · average — the other numeric terminals · find — for a null-safe "smallest matching" search