Let my submit button know which component the user has selected - Flutterflow

27 Views Asked by At

I've been trying to figure this out all weekend.l'd really appreciate it if someone showed me how to do this. l've watched videos, read documentation but I just dont get it.

I have 4 components, each with an image and they get the image url from document reference. When the user presses the submit button I want the appto compare the image url of the selcted component with a correctAnswer in the document. But I don't understand how to let the Submit button know which component has been selected.

Please help, im tearing my hair out over this.

I've watched countless videos and read the FF documentation on execute callback a million times but I just don't understand. I can't seem to let the Submit button know which component has been selected.

1

There are 1 best solutions below

0
Vandan Patel On

You can simply make list and on tap take that selected item(image) index and use that index while submit.

Code -

 ListView.builder(
                    itemCount: 4,
                    itemBuilder: (context, index) {
                      return InkWell(
                        onTap: () {
                          setState(() {
                            selectedItem=index;
                          });
                        },
                        child: Container(
                          decoration: BoxDecoration(
                            border: Border.all(
                              color: selectedItem == index
                                  ? Colors.blue
                                  : Colors.white,
                            ),
                          ),
                          child: Image.asset(
                              "Your_image_url"), //for network image use Image.network("src")
                        ),
                      );
                    },
                  ),