mercredi 13 octobre 2021

how to create dual checkbox in flutter

I want to create two checkbox next to each other and when one of them is checked, the other one be unchecked but I don`t know how to do that in flutter, so I'll be wonderful if someone could help me. here is my codes:

  bool isMan = false;
  bool isWoman = false;

  Padding(
                    padding: EdgeInsets.only(right: 10),
                    child: Text(
                      "Man:",
                      style: TextStyle(color: Colors.white, fontSize: 20),
                    ),
                  ),
                  Theme(
                    data: ThemeData(unselectedWidgetColor: Colors.white),
                    child: Checkbox(
                      value: isMan,
                      checkColor: Color(0xfff44336),
                      activeColor: Colors.white,
                      onChanged: (value) {
                        setState(
                          () {
                            isMan = value!;
                          },
                        );
                      },
                    ),
                  ),
                  Text(
                    "Woman:",
                    style: TextStyle(color: Colors.white, fontSize: 20),
                  ),
                  Theme(
                    data: ThemeData(unselectedWidgetColor: Colors.white),
                    child: Checkbox(
                      value: isWoman,
                      checkColor: Color(0xfff44336),
                      activeColor: Colors.white,
                      onChanged: (value) {
                        setState(
                          () {
                            isWoman = value!;
                          },
                        );
                      },
                    ),
                  ),



Aucun commentaire:

Enregistrer un commentaire