dart-lang / collection

The collection package for Dart contains a number of separate libraries with utility functions and classes that makes working with collections easier.

Home Page:https://pub.dev/packages/collection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a `whereNull()` or a `nullsCount` to iterable extension

ValentinVignal opened this issue · comments

It would be useful to know the number of null in an iterable. For now, I'm creating my own.

extension on Iterable {
  int nullsCount => where((element) => element == null).length;
}
commented

Feels like this functionality is very specific to your projects business logic and not so much a general one.