From 2a127e7fbafe2dc45b02aa644b2b2faee657fe6a Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Thu, 9 Jul 2015 19:28:44 -0400 Subject: [PATCH] Fix crash when toggling "Everything is awesome" in Stock's Settings. Material.backgroundColor can be null. R=ianh@google.com Review URL: https://codereview.chromium.org/1225153003 . --- sdk/lib/widgets/material.dart | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/sdk/lib/widgets/material.dart b/sdk/lib/widgets/material.dart index 8b6311931f8..9cd6a97ea11 100644 --- a/sdk/lib/widgets/material.dart +++ b/sdk/lib/widgets/material.dart @@ -34,7 +34,7 @@ class Material extends AnimatedComponent { if (level == null) level = 0; _container = new AnimatedContainer() ..shadow = new AnimatedType(level.toDouble()) - ..backgroundColor = new AnimatedColor(_getBackgroundColor(type, color)) + ..backgroundColor = _getBackgroundColor(type, color) ..borderRadius = edges[type] ..shape = type == MaterialType.circle ? Shape.circle : Shape.rectangle; watchPerformance(_container.createPerformance( @@ -53,17 +53,14 @@ class Material extends AnimatedComponent { super.syncFields(source); } - Color _getBackgroundColor(MaterialType type, Color color) { - if (color != null) - return color; - switch (type) { - case MaterialType.canvas: - return Theme.of(this).canvasColor; - case MaterialType.card: - return Theme.of(this).cardColor; - default: - return null; + AnimatedColor _getBackgroundColor(MaterialType type, Color color) { + if (color == null) { + switch (type) { + case MaterialType.canvas: color = Theme.of(this).canvasColor; break; + case MaterialType.card: color = Theme.of(this).cardColor; break; + } } + return color == null ? null : new AnimatedColor(color); } Widget build() {