flutter / flutter/flutter-intellij
[CQ] ☂ fix nullability problems
- Dominant language
- Java
- Stars
- 2k
- Forks
- 356
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 27
Description
A tracking issue for fixing nullability problems, where possible with [@NotNull and @Nullable annotations](https://www.jetbrains.com/idea/docs/NullableHowTo.pdf).
## Motivation
[Null Pointer Exceptions](https://docs.oracle.com/javase/8/docs/api/java/lang/NullPointerException.html) are a significant issue in Java and the plugin in particular. While Java doesn't have native, compile-time null safety like Kotlin (or [Dart](https://dart.dev/null-safety)), Jetbrains provides [@NotNull and @Nullable annotations](https://www.jetbrains.com/idea/docs/NullableHowTo.pdf) to document nullability contracts with static and runtime enforcement. Static enforcement gives code authors feedback in the editor if they pass a possibly null value where a non-null one is expected. In addition, the compiler [adds assertions](https://www.jetbrains.com/help/idea/annotating-source-code.html) to all code elements annotated with @NotNull, providing a runtime check and making any explicit null-checks redundant and unnecessary. @NotNull and @Nullable are in use already (2297 and 857 times respectively) but not consistently and the question of whether to use them on new code has come up in code review (e.g., [pull#8247](https://github.com/flutter/flutter-intellij/pull/8247/files/7497a24d5897b96257c2dc870d8ba2ce8fc4018c#r2132562982)).
## Approach
Detecting code is easy with the built-in inspection:

To ensure we don't regress, it would be great to update the plugin verify to flag new nullability problems (https://github.com/flutter/flutter-intellij/issues/8292).
Contributor guide
Assessment
This issue has not been assessed yet.