resolveBackgroundColor static method

WidgetStateProperty<Color?> resolveBackgroundColor(
  1. BuildContext context,
  2. OudsButtonHierarchy hierarchy,
  3. OudsButtonStyle? style
)

Implementation

static WidgetStateProperty<Color?> resolveBackgroundColor(
  BuildContext context,
  OudsButtonHierarchy hierarchy,
  OudsButtonStyle? style,
) {
  return WidgetStateProperty.resolveWith<Color?>(
    (Set<WidgetState> states) {
      if (style == OudsButtonStyle.loading) {
        return ButtonLoadingModifier.getBackgroundToken(context, hierarchy);
      }

      if (states.contains(WidgetState.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);
    },
  );
}