From 4d958ea5b7fd949f40bbad713130e923a56fddba Mon Sep 17 00:00:00 2001 From: Shi-Hao Hong Date: Sat, 30 Mar 2019 12:58:58 -0700 Subject: [PATCH] Added helpful Material assert message (#30219) Clarified an assert for when a Material widget's backgroundColor is null when its type isn't MaterialType.transparency --- packages/flutter/lib/src/material/material.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/material.dart b/packages/flutter/lib/src/material/material.dart index cb958216b8..82bcaa421c 100644 --- a/packages/flutter/lib/src/material/material.dart +++ b/packages/flutter/lib/src/material/material.dart @@ -320,7 +320,13 @@ class _MaterialState extends State with TickerProviderStateMixin { @override Widget build(BuildContext context) { final Color backgroundColor = _getBackgroundColor(context); - assert(backgroundColor != null || widget.type == MaterialType.transparency); + assert( + backgroundColor != null || widget.type == MaterialType.transparency, + 'If Material type is not MaterialType.transparency, a color must ' + 'either be passed in through the `color` property, or be defined ' + 'in the theme (ex. canvasColor != null if type is set to ' + 'MaterialType.canvas)' + ); Widget contents = widget.child; if (contents != null) { contents = AnimatedDefaultTextStyle(