avoid_non_null_assertion
Rule which warns about usages of bang operator ("!") as it may result in unexpected runtime exceptions.
"Bang" operator with Maps is allowed, as Dart docs recommend using it for accessing Map values that are known to be present.
Example config:
plugins:
solid_lints:
diagnostics:
avoid_non_null_assertion:
ignored_types:
- IMap
- BuiltMap
Example
BAD:
Object? object;
int? number;
final int computed = 1 + number!; // LINT
object!.method(); // LINT
GOOD:
Object? object;
int? number;
if (number != null) {
final int computed = 1 + number;
}
object?.method();
// No lint on maps
final map = {'key': 'value'};
map['key']!;
Parameters
ignored_types (Set<String>)
Types that would be ignored by avoid-non-null-assertion rule
Example:
plugins:
solid_lints:
diagnostics:
avoid_non_null_assertion:
ignored_types:
- IMap
IMap<String, String> map;
map['key']!; // OK