baseStyle static method

ButtonStyle baseStyle({
  1. required MihrButtonSize size,
  2. OutlinedBorder? shape,
  3. bool isSquare = false,
})

Structural-only ButtonStyle for a regular (non-link) button.

Contains shape, size constraints, padding, text style, icon size, splash factory, animation duration, and cursor. Does NOT contain backgroundColor, foregroundColor, side, or elevation.

Implementation

static ButtonStyle baseStyle({
  required MihrButtonSize size,
  OutlinedBorder? shape,
  bool isSquare = false,
}) {
  final effectiveShape = shape ??
      const RoundedRectangleBorder(borderRadius: MihrRadius.borderMd);
  final ts = TextStyle(
    fontSize: size.fontSize,
    fontWeight: FontWeight.w600,
  );

  if (isSquare) {
    return ButtonStyle(
      minimumSize: WidgetStatePropertyAll(
        Size(size.height, size.height),
      ),
      fixedSize: WidgetStatePropertyAll(
        Size(size.height, size.height),
      ),
      padding: const WidgetStatePropertyAll(EdgeInsets.zero),
      textStyle: WidgetStatePropertyAll(ts),
      iconSize: WidgetStatePropertyAll(size.iconSize),
      shape: WidgetStatePropertyAll(effectiveShape),
      overlayColor: const WidgetStatePropertyAll(Colors.transparent),
      splashFactory: NoSplash.splashFactory,
      tapTargetSize: MaterialTapTargetSize.shrinkWrap,
      animationDuration: const Duration(milliseconds: 100),
      mouseCursor: WidgetStateProperty.resolveWith(
        (s) => s.contains(WidgetState.disabled)
            ? SystemMouseCursors.basic
            : SystemMouseCursors.click,
      ),
    );
  }

  return ButtonStyle(
    padding: WidgetStatePropertyAll(
      EdgeInsets.symmetric(horizontal: size.paddingH),
    ),
    minimumSize: WidgetStatePropertyAll(
      Size(0, size.height),
    ),
    maximumSize: WidgetStatePropertyAll(
      Size(double.maxFinite, size.height),
    ),
    textStyle: WidgetStatePropertyAll(ts),
    iconSize: WidgetStatePropertyAll(size.iconSize),
    shape: WidgetStatePropertyAll(effectiveShape),
    overlayColor: const WidgetStatePropertyAll(Colors.transparent),
    splashFactory: NoSplash.splashFactory,
    tapTargetSize: MaterialTapTargetSize.shrinkWrap,
    animationDuration: const Duration(milliseconds: 100),
    mouseCursor: WidgetStateProperty.resolveWith(
      (s) => s.contains(WidgetState.disabled)
          ? SystemMouseCursors.basic
          : SystemMouseCursors.click,
    ),
  );
}