firstWhereOrNull<T> function
Not JSON-specific — a hand-rolled Iterable.firstWhere-or-null so the generated code doesn't need the collection package as a pub dependency.
Implementation
T? firstWhereOrNull<T>(Iterable<T> iterable, bool Function(T) test) {
for (final item in iterable) {
if (test(item)) return item;
}
return null;
}