Gabriel Costache
Gabriel Costache

Reputation: 969

How to change state of a single object inside a List

I am building an app that shows three tabs, each one shows a list of places, each list is ordered by distance, importance and user votes. How do I update a single object inside those lists (Like if it's in user's liked list) without updating the entire list every time? I am currently using a bloc pattern.

Upvotes: 0

Views: 219

Answers (1)

Pablo Barrera
Pablo Barrera

Reputation: 10963

You could create a StatefulWidget for that part so it can handle its own state, or you could wrap that part with StatefulBuilder, and use it like this:

     StatefulBuilder(
        builder: (BuildContext context, StateSetter setState) {
          return Column(
            mainAxisSize: MainAxisSize.min,
            children: List<Widget>.generate(4, (int index) {
              return Radio<int>(
                value: index,
                groupValue: selectedRadio,
                onChanged: (int value) {
                  setState(() => selectedRadio = value);
                },
              );
            }),
          );
        },
      )

Upvotes: 1

Related Questions