lundi 4 octobre 2021

How to add display button on check on checkbox

I am displaying a list of week using CheckboxGroup, now i want if user check any checkbox, let say if user check the monday checkbox then it should display button in front of it. the design should look like this

enter image description here

CheckboxGroup code is here

Container(
                  // padding: EdgeInsets.only(right: 70),
                    child: Row(
                  children: [
                    Expanded(
                        child: SizedBox(
                            height: MediaQuery.of(context).size.height * 0.45,
                            child: ListTile(
                              title: CheckboxGroup(
                                  onChange: (bool isChecked, String label,
                                          int index) =>
                                      setState(() {
                                        day = isChecked;
                                       
                                      }),
                                  labelStyle:
                                      GoogleFonts.montserrat(fontSize: 15),
                                  labels: <String>[
                                    "Monday",
                                    "Tuesday",
                                    "Wednesday",
                                    "Thursday",
                                    "Friday",
                                    "Saturday",
                                    "Sunday",
                                  ],
                                  onSelected: (List<String> checked) =>
                                      ),
                            ))),
                    SizedBox(
                      width: 10,
                    ),
                    picktimebutton(),
                  ],
                ))

I am trying to do it like this but it shows this result

enter image description here

here is the code of picktimebutton()

picktimebutton() {
    if (day == true) {
      return customButton(context, "Pick Time", (){}, 
      MediaQuery.of(context).size.width*0.3, 40.0);
    } else {
      return Padding(
          padding: const EdgeInsets.only(left: 70),
          child:
              Row(crossAxisAlignment: CrossAxisAlignment.center, children: []));
    }
  }

please help if anyone know how to do this




Aucun commentaire:

Enregistrer un commentaire