ToggleButtonThemeData.standard constructor

ToggleButtonThemeData.standard(
  1. ThemeData style
)

Implementation

factory ToggleButtonThemeData.standard(ThemeData style) {
  Color checkedColor(Set<ButtonStates> states) => states.isDisabled
      ? ButtonThemeData.buttonColor(style.brightness, states)
      : ButtonThemeData.checkedInputColor(style, states);
  Color uncheckedColor(Set<ButtonStates> states) =>
      states.isHovering || states.isPressing
          ? ButtonThemeData.uncheckedInputColor(style, states)
          : ButtonThemeData.buttonColor(style.brightness, states);

  const padding = const EdgeInsets.symmetric(horizontal: 12, vertical: 8);
  return ToggleButtonThemeData(
    checkedButtonStyle: ButtonStyle(
      zFactor: ButtonState.all(kDefaultButtonZFactor),
      cursor: style.inputMouseCursor,
      shape: ButtonState.all(
          RoundedRectangleBorder(borderRadius: BorderRadius.circular(2))),
      backgroundColor: ButtonState.resolveWith(checkedColor),
      foregroundColor: ButtonState.resolveWith((states) => states.isDisabled
          ? style.disabledColor
          : checkedColor(states).basedOnLuminance()),
      padding: ButtonState.all(padding),
    ),
    uncheckedButtonStyle: ButtonStyle(
      zFactor: ButtonState.all(kDefaultButtonZFactor),
      cursor: style.inputMouseCursor,
      shape: ButtonState.all(
          RoundedRectangleBorder(borderRadius: BorderRadius.circular(2))),
      backgroundColor: ButtonState.resolveWith(uncheckedColor),
      foregroundColor: ButtonState.resolveWith((states) => states.isDisabled
          ? style.disabledColor
          : uncheckedColor(states).basedOnLuminance()),
      padding: ButtonState.all(padding),
    ),
  );
}