attach method

  1. @override
Widget? attach(
  1. BuildContext context,
  2. RadioLayoutController controller
)
override

Implementation

@override
Widget? attach(BuildContext context, RadioLayoutController controller) {
  var titleDefaultMargin = controller.isTitledMargin ? 12.0 : 0.0;
  return Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    mainAxisAlignment: MainAxisAlignment.start,
    mainAxisSize: MainAxisSize.min,
    children: [
      TextView(
        visibility: (controller.title ?? "").isNotEmpty,
        text: controller.title,
        textColor: controller.titleColor,
        textFontWeight: controller.titleFontWeight ?? FontWeight.w600,
        textSize: controller.titleSize ?? 16,
        textStyle: controller.titleStyle,
        marginTop: controller.titleMargin?.top,
        marginBottom: controller.titleMargin?.bottom,
        marginStart: controller.titleMargin?.left ?? titleDefaultMargin,
        marginEnd: controller.titleMargin?.right,
        paddingTop: controller.titlePadding?.top,
        paddingBottom: controller.titlePadding?.bottom,
        paddingStart: controller.titlePadding?.left,
        paddingEnd: controller.titlePadding?.right,
      ),
      ...List.generate(controller.children.length, (index) {
        var item = controller.children[index];
        return RadioButton(
          background: item.background ?? controller.itemBackground,
          backgroundState:
              item.backgroundState ?? controller.itemBackgroundState,
          cornerRadius: item.cornerRadius ?? controller.itemCornerRadius,
          index: index,
          key: item.key,
          margin: item.margin ?? controller.itemMargin,
          padding: item.padding ?? controller.itemPadding,
          pressedColor: item.pressedColor ?? controller.itemPressedColor,
          rippleColor: item.rippleColor ?? controller.itemRippleColor,
          radioSelectedColor:
              item.radioSelectedColor ?? controller.itemRadioSelectedColor,
          radioUnselectedColor: item.radioUnselectedColor ??
              controller.itemRadioUnselectedColor,
          selection: controller.currentIndex,
          spaceBetween: itemSpaceBetween,
          text: item.text,
          textState: item.textState,
          textColor: item.textColor ?? controller.itemTextColor,
          textColorState:
              item.textColorState ?? controller.itemTextColorState,
          textSize: item.textSize ?? controller.itemTextSize,
          textSizeState: item.textSizeState ?? controller.itemTextSizeState,
          textStyle: item.textStyle ?? controller.itemTextStyle,
          textStyleState:
              item.textStyleState ?? controller.itemTextStyleState,
          onClick: (context, index) {
            controller.setCurrentIndex(index);
            if (onItemChange != null) onItemChange?.call(context, index ?? 0);
          },
        );
      }),
    ],
  );
}