link method

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

Implementation

Widget link({var component, required double parentWidth}) {
  LinkController linkController = LinkController();
  return Visibility(
    visible: (component["security"] == null)
        ? true
        : (component["security"]["viewable"] == true)
            ? true
            : false,
    child: SizedBox(
      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,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          AltComponent().altComponentLabel(
              component: component,
              label: (component["displayLabel"] != null &&
                      component["displayLabel"] != "")
                  ? component["displayLabel"]
                  : (component["security"] != null &&
                          component["security"]["fieldLabel"] != null &&
                          component["security"]["fieldLabel"] != "")
                      ? component["security"]["fieldLabel"]
                      : component["label"]),
          Padding(
            padding: const EdgeInsets.only(left: 8.0),
            child: MouseRegion(
              cursor: (component["linkName"] != null &&
                      component["linkName"] != "")
                  ? SystemMouseCursors.click
                  : SystemMouseCursors.basic,
              child: TextButton(
                onPressed: () {
                  if (component["linkName"] != null &&
                      component["linkName"] != "") {
                    linkController.openLink(component["linkUrl"]);
                  }
                },
                style: ButtonStyle(
                    mouseCursor: MaterialStateProperty.all<MouseCursor>(
                        MouseCursor.defer),
                    backgroundColor:
                        MaterialStateProperty.all<Color>(Colors.transparent),
                    overlayColor:
                        MaterialStateProperty.all<Color>(Colors.transparent),
                    padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
                        EdgeInsets.zero),
                    minimumSize:
                        MaterialStateProperty.all<Size>(const Size(0, 0)),
                    tapTargetSize: MaterialTapTargetSize.shrinkWrap,
                    alignment: Alignment.center),
                child: (component["linkName"] != null &&
                        component["linkName"] != "")
                    ? Text(component["linkName"], style: componentLabelStyle)
                    : const SizedBox.shrink(),
              ),
            ),
          ),
          AltComponent().altComponentInstruction(component: component)
        ],
      ),
    ),
  );
}