samedi 29 octobre 2022

How to change boolean value from a Dialog?

I need to change a Boolean value from a Dialog. It works if I have my Checkbox on my page, but not when I try it in a Dialog.

How can I get the value of ìsselected1 from my Dialog to my page?

Here is my Dialog:

IconButton(onPressed: () {
                showDialog(context: context, builder: (ctx) {
                  return StatefulBuilder(
                    builder: (context, setState) {
                      return Dialog(
                        child: SizedBox(
                          height: 200,
                          width: 100,
                          child: Column(
                            children: [
                           
                              Padding(
                                padding: const EdgeInsets.all(8.0),
                                child: Row(
                                  children: [
                                    Text('Test'),
                                    Checkbox(value: isselected1, onChanged: (value) {
                                      setState(() {
                                     
                                        isselected1 = value!;
                                      });
                                    }),
                                    
                                  ],
                                ),
                              )
                            ],
                          ),
                        ),
                      );
                    },
                  );
                });

              }, icon: Icon(Icons.add))
            ],
          ),



Aucun commentaire:

Enregistrer un commentaire