-
Notifications
You must be signed in to change notification settings - Fork 6k
add nullability annotations to ui/text.dart #18400
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed some function parameter types that look like they are missing annotations.
lib/web_ui/lib/src/ui/text.dart
Outdated
|
||
/// The text before this range. | ||
String textBefore(String text) { | ||
String/*!*/ textBefore(String text) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below do the parameters need to be annotated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
lib/web_ui/lib/src/ui/text.dart
Outdated
@@ -1423,23 +1424,23 @@ abstract class Paragraph { | |||
/// The [boxHeightStyle] and [boxWidthStyle] parameters must not be null. | |||
/// | |||
/// See [BoxHeightStyle] and [BoxWidthStyle] for full descriptions of each option. | |||
List<TextBox> getBoxesForRange(int start, int end, | |||
List<TextBox/*!*/>/*!*/ getBoxesForRange(int start, int end, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto here and below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -360,17 +360,17 @@ class TextDecoration { | |||
const TextDecoration._(this._mask); | |||
|
|||
/// Creates a decoration that paints the union of all the given decorations. | |||
factory TextDecoration.combine(List<TextDecoration> decorations) { | |||
factory TextDecoration.combine(List<TextDecoration/*!*/>/*!*/ decorations) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated question: How does nnbd handle factory constructors that return null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Factories are not allowed to return null any more.
@@ -131,7 +131,7 @@ class FontWeight { | |||
/// | |||
/// Values for `t` are usually obtained from an [Animation<double>], such as | |||
/// an [AnimationController]. | |||
static FontWeight lerp(FontWeight a, FontWeight b, double t) { | |||
static FontWeight/*?*/ lerp(FontWeight/*?*/ a, FontWeight/*?*/ b, double/*!*/ t) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
values
doesn't have any null entries:
static FontWeight/*?*/ lerp(FontWeight/*?*/ a, FontWeight/*?*/ b, double/*!*/ t) { | |
static FontWeight/*!*/ lerp(FontWeight/*?*/ a, FontWeight/*?*/ b, double/*!*/ t) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but there's also:
if (a == null && b == null)
return null;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't follow =) Could you spell it out for me a bit more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! I was looking at the lib/ui/text.dart
, where the implementation is as follows:
static FontWeight/*?*/ lerp(FontWeight/*?*/ a, FontWeight/*?*/ b, double/*!*/ t) {
assert(t != null);
if (a == null && b == null)
return null;
return values[lerpDouble(a?.index ?? normal.index, b?.index ?? normal.index, t).round().clamp(0, 8) as int];
}
I should just sync the two so they are consistent. Both should be returning FontWeight?
though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
return (direction == TextDirection.ltr) ? right : left; | ||
} | ||
|
||
@override | ||
bool operator ==(dynamic other) { | ||
bool/*!*/ operator ==(dynamic other) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does dynamic
imply ?
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes (but Object
doesn't)
The luci-engine failure is due to flutter/flutter#58785. Ignoring it. |
Related Issues
flutter/flutter#53661