build method

  1. @override
Widget build(
  1. BuildContext context
)
override

현재 상태에 맞는 내용과 스타일의 Material 버튼을 빌드한다.

Implementation

@override
Widget build(BuildContext context) {
  return SafeArea(
    top: safeArea,
    bottom: safeArea,
    left: safeArea,
    right: safeArea,
    child: Padding(
      padding: margin,
      child: ElevatedButton(
        onPressed: () async {
          if (!enabled || isPending) {
            return;
          }

          onPressed();
        },
        style: ElevatedButton.styleFrom(
          padding: padding,
          minimumSize: minimumSize ?? Size(0.0, height),
          backgroundColor: backgroundColor ?? (outlined
              ? Colors.white
              : enabled ? disabledBackgroundColor : Colors.grey[200]),
          shape: border ?? RoundedRectangleBorder(
            borderRadius: borderRadius ?? BorderRadius.circular(rounded ? height / 2 : 8.0),
            side: outlined
                ? BorderSide(
                    color: enabled
                        ? foregroundColor ?? DN.theme.primaryColor
                        : disabledBackgroundColor ?? Colors.grey[200]!,
                  )
                : BorderSide.none,
          ),
          foregroundColor: outlined ? (foregroundColor ?? DN.theme.primaryColor) : Colors.white,
        ),
        child: isPending
            ? pendingChild ??
                  SizedBox(
                    width: 18.0,
                    height: 18.0,
                    child: Center(
                      child: CircularProgressIndicator.adaptive(
                        strokeWidth: 3.0,
                        valueColor: AlwaysStoppedAnimation<Color>(
                          progressColor ?? (outlined ? (foregroundColor ?? DN.theme.primaryColor) : Colors.white),
                        ),
                      ),
                    ),
                  )
            : enabled
            ? child
            : disabledChild ?? child,
      ),
    ),
  );
}