avoid-nullable-tostring
preset: recommended
Warns when the toString
method is called on a nullable value.
Calling toString
on a nullable value can result in an unexpected output (e.g. 'null').
Example
❌ Bad:
void fn(String? nullableValue) {
print(nullableValue.toString()); // LINT
}
✅ Good:
void fn(String? nullableValue) {
print(nullableValue?.toString());
}