predicates

A small family of type/value checks, kept around as tear-off-friendly functions for filter, takeWhile, and friends.

bool fxIsNull(Object? a) bool isNotNull(Object? a) bool fxIsNil(Object? a) // == isNull; Dart has no separate `undefined` bool fxIsBool(Object? a) bool fxIsNum(Object? a) bool fxIsString(Object? a) bool isDateTime(Object? a) bool fxIsList(Object? a) bool fxIsMap(Object? a)

Lecture

In everyday Dart you'd just write a is String — that's idiomatic, and nothing here replaces it. These functions exist for one specific reason: Dart's is operator can't be torn off as a first-class function value, but filter, takeWhile, find, and friends all want a bool Function(A). fxFilter(fxIsString, mixedList) reads better than fxFilter((a) => a is String, mixedList), and that's the whole point of this page.

fxIsNil is a straight port of FxTS's "is null or undefined" check — since Dart collapses both into null, it's byte-for-byte identical to fxIsNull. Three more names exist purely for FxTS parity and are marked @Deprecated: fxIsUndefined (there's no undefined in Dart, so it's just fxIsNull), fxIsArray (JS Array → Dart List, so it's fxIsList), and fxIsObject (JS plain object → Dart Map, so it's fxIsMap). Reach for the non-deprecated name in new code; the aliases are there so ported call sites still compile.

Demo 1 · Filter-friendly tear-offs

Demo 2 · fxIsNil and the deprecated aliases

Try it yourself

Exercise: use isNotNull to filter the null out of row.

Related: filter — the usual place these get plugged in · fxIsEmpty — a value-based check, not a type check · fxCompact — drop nulls from an iterable · fxMatches — a predicate for shape, not type