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
This commit is contained in:
Shi-Hao Hong
2019-03-30 12:58:58 -07:00
committed by GitHub
parent f5b0a081e6
commit 4d958ea5b7

View File

@@ -320,7 +320,13 @@ class _MaterialState extends State<Material> 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(