getDisabledTextColor method Null safety

Color getDisabledTextColor(
  1. MaterialButton button
)

The foreground color of the button's text and icon when MaterialButton.onPressed is null (when MaterialButton.enabled is false).

Returns the button's MaterialButton.disabledColor if it is non-null. Otherwise the color scheme's ColorScheme.onSurface color is returned with its opacity set to 0.38.

If MaterialButton.textColor is a MaterialStateProperty<Color>, it will be used as the disabledTextColor. It will be resolved in the MaterialState.disabled state.

Implementation

Color getDisabledTextColor(MaterialButton button) {
  return button.textColor ?? button.disabledTextColor ?? colorScheme!.onSurface.withOpacity(0.38);
}