resolveBackgroundColor static method
Implementation
static WidgetStateProperty<Color?> resolveBackgroundColor(
BuildContext context,
OudsButtonHierarchy hierarchy,
OudsButtonControlState? buttonState,
) {
return WidgetStateProperty.resolveWith<Color?>(
(Set<WidgetState> states) {
if (buttonState == OudsButtonControlState.loading) {
return OudsButtonLoadingModifier.getBackgroundToken(context, hierarchy);
}
// Handles both Flutter's native pressed state and custom OudsButton state.
// `states` is the standard WidgetState set, while `buttonState` is a custom control enum.
if (states.contains(WidgetState.pressed) || (buttonState != null && buttonState == OudsButtonControlState.pressed)) {
return _getPressedColor(context, hierarchy);
} else if (states.contains(WidgetState.hovered)) {
return _getHoverColor(context, hierarchy);
} else if (states.contains(WidgetState.disabled)) {
return _getDisabledColor(context, hierarchy);
}
return _getEnabledColor(context, hierarchy);
},
);
}