'Flutter : Why it does not work then I tap the button?

I want that it change the state of the checked button of the checkbox but it does not change anything, why ? I have even not any print at the screen for print('coucou')... ?

if (!answerControllers.containsKey(question["id"])) {
  answerControllers[question["id"]] = new Map<dynamic, dynamic>();
  if (previousValue == null) {
    for (dynamic answer in answersToQuestion)
    if(answerControllers[question["id"]][answer["libelle"]] != null) 
      answerControllers[question["id"]][answer["libelle"]]['checked'] = false;
  } else {
    for (dynamic answer in answersToQuestion) {
      if (previousValue
              .toString()
              .indexOf("|||" + answer["libelle"] + "|||") ==
          -1) {
        answerControllers[question["id"]][answer["libelle"]]['checked'] = true;
      } else {
        answerControllers[question["id"]][answer["libelle"]]['checked'] = false;
      }
    }
  }
  
}

and

 widget = Container(
            padding: EdgeInsets.zero,
            margin: EdgeInsets.all(1),
            decoration: BoxDecoration(
              border: Border.all(
                color: !errors.contains(question["id"])
                    ? Colors.white
                    : Colors.red[700],
                width: 1,
              ),
              borderRadius: BorderRadius.circular(5),
            ),
            child: Column(
              children: 
              [
                for (dynamic answer in answersToQuestion) 
                Container(
                  child:
                    Column(
                      children: [
                        Row(
                          children: [
                            Checkbox(
                              activeColor: Style.primaryColor,
                              onChanged: (value) {
                                print('coucou');
                                setState(() {
                                  (answerControllers[question["id"]][answer["libelle"]] != null) ? 
                                  (answerControllers[question["id"]][answer["libelle"]]['checked'] = value) : true;
                                });
                              },
                              value: (answerControllers[question["id"]][answer["libelle"]] != null) ? answerControllers[question["id"]]
                                  [answer["libelle"]]['checked'] : false,
                            ),
                            Expanded(
                                child: FlatButton(
                                    padding: EdgeInsets.all(0),
                                    onPressed: () {
                                      setState(() {
                                        (answerControllers[question["id"]][answer["libelle"]] != null) ?
                                        answerControllers[question["id"]]
                                                [answer["libelle"]]['checked'] =
                                            !answerControllers[question["id"]]
                                                [answer["libelle"]]['checked'] : null;
                                      });
                                    },
                                    child: Align(
                                      alignment: Alignment.centerLeft,
                                      child: Text(
                                        answer["libelle"],
                                        overflow: TextOverflow.ellipsis,
                                      ),
                                    ))) 
                          ],
                        ),
                        Row(
                          children: [
                            Visibility (
                              visible: (answerControllers[question["id"]]
                                      [answer["libelle"]] != null) ? answerControllers[question["id"]]
                                      [answer["libelle"]]['checked'] : false,
                              child: (
                                
                                Expanded(
                                  child: 
                                  TextField(
                                    controller: (answerControllers[question["id"]][answer["libelle"]] != null) ? answerControllers[question["id"]][answer["libelle"]]['precisions'] : null,
                                    keyboardType: TextInputType.name,
                                    decoration: new InputDecoration(
                                        hintText: answer["precisions"],
                                        border: new OutlineInputBorder(
                                            borderSide: new BorderSide(color: Colors.grey)),
                                        prefixText: '',
                                        focusedBorder: new OutlineInputBorder(
                                            borderSide:
                                                new BorderSide(color: Style.primaryColor, width: 2)),
                                        errorText:
                                            !errors.contains(question["id"]) ? null : obligatoryField,
                                        suffixStyle: const TextStyle(color: Colors.grey)),
                                  )
                                )
                              )
                            )
                        ],)
                    ],)
                
                )
              ],
            ));
        break;

I want to understand why when I tap to the button, it does not change any value nor print anything, I made researches but I didn't found anything relevant



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source