getStyleWithAdjustments method

ButtonStyle getStyleWithAdjustments({
  1. required BuildContext context,
  2. required ButtonType buttonType,
})

Implementation

ButtonStyle getStyleWithAdjustments({
  required BuildContext context,
  required ButtonType buttonType,
}) {
  ButtonStyle getButtonStyle() {
    switch (buttonType) {
      case ButtonType.text:
        return Theme.of(context).textButtonTheme.style!;
      case ButtonType.outlined:
        return Theme.of(context).outlinedButtonTheme.style!;
    }
  }

  ButtonStyle buttonStyle = style ?? getButtonStyle();
  MaterialStateProperty<Size>? buttonSize =
      size == null ? null : MaterialStateProperty.all<Size>(size!);

  return buttonStyle.copyWith(
    maximumSize: buttonSize ?? buttonStyle.maximumSize,
    minimumSize: buttonSize ?? buttonStyle.minimumSize,
  );
}