label method

Widget label({
  1. dynamic component,
  2. required double parentWidth,
})

Implementation

Widget label({var component, required double parentWidth}) {
  double width =
      (component["cssClass"] != null && component["cssClass"] != "")
          ? SwitchCase().componentWidthSC(
              component["cssClass"],
              {
                "layout_1by8_col": parentWidth * 0.1,
                "layout_1_col": parentWidth * 0.2,
                "layout_2_col": parentWidth * 0.4,
                "layout_3_col": parentWidth * 0.68,
                "layout_4_col": parentWidth,
              },
              parentWidth * 0.2)
          : parentWidth * 0.2;
  return SizedBox(
    width: width,
    child: Center(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Wrap(
            children: [
              Padding(
                padding: const EdgeInsets.only(right: 10.0),
                child: Container(
                  constraints: BoxConstraints(
                    maxWidth: (maxWordWidth(
                                ((component["displayLabel"] != null &&
                                        component["displayLabel"] != "")
                                    ? component["displayLabel"]
                                    : (component["security"] != null
                                        ? component["security"]["fieldLabel"]
                                        : "")),
                                component,
                                false)
                            .isGreaterThan(component["labelWidth"] != null
                                ? (SwitchCase().labelComponentWidthSC(
                                    component["labelWidth"],
                                    {
                                      "10": width * 0.1,
                                      "20": width * 0.2,
                                      "30": width * 0.3,
                                      "40": width * 0.4,
                                      "50": width * 0.5,
                                      "60": width * 0.6,
                                      "70": width * 0.7,
                                      "80": width * 0.8,
                                      "90": width * 0.9,
                                      "0": width,
                                    },
                                    width * 0.46))
                                : width * 0.46))
                        ? maxWordWidth(
                            ((component["displayLabel"] != null &&
                                    component["displayLabel"] != "")
                                ? component["displayLabel"]
                                : (component["security"] != null
                                    ? component["security"]["fieldLabel"]
                                    : "")),
                            component,
                            false)
                        : component["labelWidth"] != null
                            ? (SwitchCase().labelComponentWidthSC(
                                component["labelWidth"],
                                {
                                  "10": width * 0.1,
                                  "20": width * 0.2,
                                  "30": width * 0.3,
                                  "40": width * 0.4,
                                  "50": width * 0.5,
                                  "60": width * 0.6,
                                  "70": width * 0.7,
                                  "80": width * 0.8,
                                  "90": width * 0.9,
                                  "0": width,
                                },
                                width * 0.46))
                            : width * 0.46, // minimum width
                  ),
                  child: Text(
                      ((component["displayLabel"] != null &&
                                  component["displayLabel"] != "")
                              ? component["displayLabel"]
                              : (component["security"] != null
                                  ? component["security"]["fieldLabel"]
                                  : "")) +
                          ":",
                      textAlign: TextAlign.end,
                      style: altLabelTxtStyle(
                          component: component, isValue: false)),
                ),
              ),
              SizedBox(
                width: component["valueWidth"] != null
                    ? (SwitchCase().labelComponentWidthSC(
                        component["valueWidth"],
                        {
                          "10": width * 0.1,
                          "20": width * 0.2,
                          "30": width * 0.3,
                          "40": width * 0.4,
                          "50": width * 0.5,
                          "60": width * 0.6,
                          "70": width * 0.7,
                          "80": width * 0.8,
                          "90": width * 0.9,
                          "0": width,
                        },
                        width * 0.5))
                    : width * 0.5,
                child: Text(
                    ((component["fieldValue"] != null &&
                            component["fieldValue"] != "")
                        ? component["fieldValue"]
                        : component["value"].toString()),
                    textAlign: TextAlign.start,
                    style: altLabelTxtStyle(
                        component: component, isValue: true)),
              ),
            ],
          ),
          AltComponent().altComponentInstruction(component: component)
        ],
      ),
    ),
  );
}