testNullability method

bool testNullability([
  1. List<StringTester> nullabilityRules = const []
])

Tests a nullability of any string following the base nullability rule, plus a list of any nullable comparators. If the value is nullable or matches any of the nullable values, returns true;

If no parameters are passed, has the same effect as String.isNullable

final String nullable = 'None';

nullable.testNullability() -> false;
nullable.testNullability(['None']) -> true;

! ATTENTION: This method is case sensitive

Implementation

bool testNullability([List<StringTester> nullabilityRules = const []]) {
  if (isNullable) return true;

  return nullabilityRules.any((rule) => rule(this!) == true);
}