getFillColor method

Color? getFillColor(
  1. MaterialButton button

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 the fill color depends on the value of getTextTheme.


Color? getFillColor(MaterialButton button) {
  final Color? fillColor = button.enabled ? button.color : button.disabledColor;
  if (fillColor != null) {
    return fillColor;

  if (button.runtimeType == MaterialButton) {
    return null;

  if (button.enabled && _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);