-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Null safety feedback: Null check should allow type promotion but doesn't #44327
Comments
Here is another example in my own code: @override
RotatableString get current {
if (_currentTextRun == null) {
throw StateError(
'Current is undefined before moveNext is called or after last element.');
}
return _currentTextRun!;
} The ! operator is required even though |
This is working as intended. Type promotion is only applicable to local variables. |
@eernstg Thank you for that explanation. I had misunderstood how it worked. That makes sense now. |
I'm upgrading a personal package that is based on the Flutter framework. I noticed here in the Flutter Text widget source code that there is a null check:
However,
textSpan!
is still using the ! operator. Shouldn'ttextSpan
be promoted to a non-nullable type without having to use the ! operator? However, trying to remove the operator gives the following error:The text was updated successfully, but these errors were encountered: