getButton method

Widget getButton(
  1. List<CarouselButton> buttons
)

Implementation

Widget getButton(List<CarouselButton> buttons) {
  return buttons.length > 1
      ? ListView.builder(
          physics: const BouncingScrollPhysics(),
          shrinkWrap: true,
          itemCount: buttons.length,
          itemBuilder: (context, indx) {
            return SingleTapEventElevatedButton(
                loader: const SizedBox(
                    height: 10,
                    width: 10,
                    child: CircularProgressIndicator()),
                style: ElevatedButton.styleFrom(
                    // visualDensity: ,
                    surfaceTintColor: Colors.transparent,
                    shadowColor: Colors.transparent,
                    disabledForegroundColor: Colors.transparent,
                    backgroundColor: Colors.transparent,
                    elevation: 0,
                    disabledBackgroundColor: Colors.transparent,
                    foregroundColor: Colors.transparent),
                onPressed: () {
                  sendMessage(buttons[indx].payload.toString(),
                      buttons[indx].text.toString());
                },
                onPressedLoading: () {},
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Divider(
                      color: HexColor('#8c8c8e'),
                    ),
                    Padding(
                      padding: const EdgeInsets.only(bottom: 5),
                      child: Text(
                        buttons[indx].text!,
                        style: TextStyle(
                            color: HexColor(color.messageClientColor!),
                            fontWeight: FontWeight.w600,
                            fontSize: 15),
                      ),
                    ),
                  ],
                ));
          },
        )
      : SingleTapEventElevatedButton(
          loader: const SizedBox(
              height: 10, width: 10, child: CircularProgressIndicator()),
          style: ElevatedButton.styleFrom(
              surfaceTintColor: Colors.transparent,
              shadowColor: Colors.transparent,
              disabledForegroundColor: Colors.transparent,
              backgroundColor: Colors.transparent,
              elevation: 0,
              disabledBackgroundColor: Colors.transparent,
              foregroundColor: Colors.transparent),
          onPressed: () {
            sendMessage(
                buttons[0].payload.toString(), buttons[0].text.toString());
          },
          onPressedLoading: () {},
          child: Column(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Divider(
                color: HexColor('#8c8c8e'),
              ),
              Padding(
                padding: const EdgeInsets.only(bottom: 5),
                child: Text(
                  buttons[0].text!,
                  style: TextStyle(
                      color: HexColor(color.messageClientColor!),
                      fontWeight: FontWeight.w600,
                      fontSize: 15),
                ),
              ),
            ],
          ),
        );
}