isEmpty for Iterables and Maps.
This rule is available as of Dart 2.0.0.
This rule has a quick fix available.
length to see if a collection is empty.
Iterable contract does not require that a collection know its length or be
able to provide it in constant time. Calling
length just to see if the
collection contains anything can be painfully slow.
Instead, there are faster and more readable getters:
isNotEmpty. Use the one that doesn’t require you to negate the result.
if (lunchBox.length == 0) return 'so hungry...'; if (words.length != 0) return words.join(' ');
if (lunchBox.isEmpty) return 'so hungry...'; if (words.isNotEmpty) return words.join(' ');
To enable the
prefer_is_empty under linter > rules in your
linter: rules: - prefer_is_empty