From f388bd30a8fdf2d01a34e12af226c413f2b889c1 Mon Sep 17 00:00:00 2001 From: Yegor Date: Fri, 25 Oct 2019 13:41:46 -0700 Subject: [PATCH] Web: fix Color subclass handling (flutter/engine#13359) --- engine/src/flutter/lib/web_ui/lib/src/ui/painting.dart | 2 +- engine/src/flutter/lib/web_ui/test/color_test.dart | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/lib/web_ui/lib/src/ui/painting.dart b/engine/src/flutter/lib/web_ui/lib/src/ui/painting.dart index ed1a4a392f..5befab9acb 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/ui/painting.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/ui/painting.dart @@ -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. diff --git a/engine/src/flutter/lib/web_ui/test/color_test.dart b/engine/src/flutter/lib/web_ui/test/color_test.dart index 863fa4f42f..8a4e9bf914 100644 --- a/engine/src/flutter/lib/web_ui/test/color_test.dart +++ b/engine/src/flutter/lib/web_ui/test/color_test.dart @@ -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 {