dart nullability checking method

31 views Asked by At

I have a method bool isNotEmpty(dynamic e), where i check nullability myself based on few criteria (e.toString() == null.toString(), e.length for String's and List's, etc.). my question is, I have a piece of code like this:

String e = 'a';
if (isNotEmpty(e)) {
   print(e);
}

how do I let dart be aware that the isNotEmpty method is ensuring that e is not null, and do not have to write print(e!) for every use of the method?

0

There are 0 answers