Unverified Commit 4d958ea5 authored by Shi-Hao Hong's avatar Shi-Hao Hong Committed by GitHub

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
parent f5b0a081
......@@ -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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment