I am getting date from FireBase via a futurebuilder.

It returns a Row whose children is a list of a widget i created called SmallDogCard (since my app is about dogs).

On a screen i want users to be able to press on the SmallDogCard to select it and change the border color, howerver. This causes the futurebuilder to load the data again... How should i approach this?

My code:


                                future: DogOwnerModel().getUserData(),
                                builder: (context, snapshot) {
                                  if (snapshot.hasError) {
                                    return Text('error');
                                  if (snapshot.connectionState ==
                                      ConnectionState.done) {
                                    List<SmallDogCard> dogCardList = [];
                                    final userData =
                               as Map<String, dynamic>;

                                    List<Map<String, dynamic>>? userDogs =
                                        userData['user dog data'];
                                    if (userDogs == null) {
                                      return Text('no dogs yet');
                                    } else {
                                      for (Map<String, dynamic> dog
                                          in userDogs) {
                                            dogName: dog['name'],
                                            imageUrl: dog['profile image'],
                                            isSelected: selectedDogs
                                                ? true
                                                : false,
                                            selectCallback: selectDogCallback));
                                      return Row(
                                          children: dogCardList);
                                  return Text('Loading');

Onpress function callback passed to the SmallDogCard (which uses setstate and makes the futurbuilder get the data again).

selectDogCallback(String name, bool isSelected) {
    if (isSelected == false) {
    } else {
    setState(() {

How can i accomplish this without the futurebuilder being called again? So i can setstate which changes the border color of the SmallDogCard which is returned from the FutureBuilder.

Thank you in advance!

Solution 1: Victor Kennedy

Problem solved!

Initializing the future in initstate, so after initstate it wont be called again!

Like this:

  void initState() {
    // TODO: implement initState
    _future = setFuture();

  setFuture() async {
    return await DogOwnerModel().getUserData(email: email);