Web: fix Color subclass handling (flutter/engine#13359)

This commit is contained in:
Yegor
2019-10-25 13:41:46 -07:00
committed by GitHub
parent 791ae7a4a2
commit f388bd30a8
2 changed files with 7 additions and 1 deletions

View File

@@ -1055,7 +1055,7 @@ class Paint {
_paintData = _paintData.clone();
_frozen = false;
}
_paintData.color = value;
_paintData.color = value.runtimeType == Color ? value : Color(value.value);
}
/// Whether the colors of the image are inverted when drawn.

View File

@@ -146,6 +146,12 @@ void main() {
// Call base class member, make sure it uses overridden value.
expect(color.red, 0xE0);
});
test('Paint converts Color subclasses to plain Color', () {
final DynamicColorClass color = DynamicColorClass(0xF0E0D0C0);
final Paint paint = Paint()..color = color;
expect(paint.color.runtimeType, Color);
});
}
class DynamicColorClass extends Color {