getFillColor method
The button's background fill color or null for buttons that don't have a background color.
Returns MaterialButton.color if it is non-null and the button is enabled.
Otherwise, returns MaterialButton.disabledColor if it is non-null and the button is disabled.
Otherwise, if button is a FlatButton or an OutlineButton then null is returned.
Otherwise, if button is a RaisedButton, returns the buttonColor
constructor parameter if it was non-null and the button is enabled.
Otherwise the fill color depends on the value of getTextTheme.
- ButtonTextTheme.normal or ButtonTextTheme.accent, the
color scheme's ColorScheme.primary color if the
button
is enabled the value of getDisabledFillColor otherwise. - ButtonTextTheme.primary, if the
button
is enabled then the value of thebuttonColor
constructor parameter if it is non-null, otherwise the color scheme's ColorScheme.primary color. If the button is not enabled then the colorScheme's ColorScheme.onSurface color with opacity 0.12.
Implementation
Color getFillColor(MaterialButton button) {
final Color fillColor = button.enabled ? button.color : button.disabledColor;
if (fillColor != null)
return fillColor;
if (button is FlatButton || button is OutlineButton)
return null;
if (button.enabled && button is RaisedButton && _buttonColor != null)
return _buttonColor;
switch (getTextTheme(button)) {
case ButtonTextTheme.normal:
case ButtonTextTheme.accent:
return button.enabled ? colorScheme.primary : getDisabledFillColor(button);
case ButtonTextTheme.primary:
return button.enabled
? _buttonColor ?? colorScheme.primary
: colorScheme.onSurface.withOpacity(0.12);
}
assert(false);
return null;
}