提交 c6300238 编写于 作者: H Hixie

Make Offset, Point, and Size more resilient

Turns out you can create these with null values, so toString() shouldn't
assume the values aren't null.
上级 2e1051ab
......@@ -64,5 +64,5 @@ class Offset extends OffsetBase {
/// Compares two Offsets for equality.
bool operator ==(dynamic other) => other is Offset && super == other;
String toString() => "Offset(${dx.toStringAsFixed(1)}, ${dy.toStringAsFixed(1)})";
String toString() => "Offset(${dx?.toStringAsFixed(1)}, ${dy?.toStringAsFixed(1)})";
}
......@@ -49,5 +49,5 @@ class Point {
int get hashCode => hashValues(x, y);
String toString() => "Point(${x.toStringAsFixed(1)}, ${y.toStringAsFixed(1)})";
String toString() => "Point(${x?.toStringAsFixed(1)}, ${y?.toStringAsFixed(1)})";
}
......@@ -66,5 +66,5 @@ class Size extends OffsetBase {
/// Compares two Sizes for equality.
bool operator ==(dynamic other) => other is Size && super == other;
String toString() => "Size(${width.toStringAsFixed(1)}, ${height.toStringAsFixed(1)})";
String toString() => "Size(${width?.toStringAsFixed(1)}, ${height?.toStringAsFixed(1)})";
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册