buildContent method

Widget buildContent()

Implementation

Widget buildContent() {
  Color? buttonColor;
  buttonColor = color is Gradient
      ? null
      : plain
          ? Style.buttonPlainBackgroundColor
          : (color ?? colors[type]["buttonColor"]);
  Color? buttonTextColor = (textColor ??
      (plain
          ? (color ?? colors[type]["buttonColor"])
          : ((color != null) && type == 'default'
              ? Colors.white
              : colors[type]["textColor"])));

  return Container(
    width: width ?? null,
    height: height ?? sizes[size]["height"],
    padding: padding ?? sizes[size]["padding"],
    child: Row(
      mainAxisAlignment: MainAxisAlignment.center,
      mainAxisSize: block ? MainAxisSize.max : MainAxisSize.min,
      children: <Widget>[
        loading
            ? SizedBox(
                width: sizes[size]["fontSize"],
                height: sizes[size]["fontSize"],
                child: CircularProgressIndicator(
                  valueColor: AlwaysStoppedAnimation(buttonTextColor),
                  backgroundColor: buttonColor,
                  strokeWidth: Style.borderWidthBase,
                ),
              )
            : (icon != null ? icon : Container()) ?? Container(),
        (loading || icon != null) && text != null
            ? SizedBox(width: Style.intervalSm)
            : Container(),
        text != null
            ? Text(text!,
                style: TextStyle(
                    color: buttonTextColor,
                    fontSize: sizes[size]["fontSize"]))
            : Container(),
      ],
    ),
  );
}