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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user