From the last time I used Flutter in 2020 until now a lot has changed. Especially everything related to null values and the famous null-safety, which brings us many headaches.
What I raise is a theoretical doubt that I cannot understand. Taking this code snippet as an example:
widget.argForm == null ? "Add new form" : "Edit form",
It is a conditional where I want one thing or another to be written depending on whether or not the object is null. Here I get a warning that says the following:
The operand can't be null, so the condition is always false. (Documentation) Try removing the condition, an enclosing condition, or the whole conditional statement.
However, in practice, this condition works fine, and it is not the case that the condition will always be false.
I would like to know how this is possible or if there is a more correct way to do this type of comparison in Dart. Also if it is something that could cause problems in the future, or that it is just a simple warning that you should not pay attention to.
The null-safety thing at first is a bit heavy to understand, but then it becomes easy, I leave you this tutorial so you can understand it better: https://dart.dev/null-safety/understanding-null-safety
About your error, surely in your widget, you have defined the variable as non-nulabe.
So when doing the validation, the analyzer tells you that this variable will never be null, so the condition will always be false:
If you had defined your variable as nullable, like this:
Then you would no longer have the warning.