flutter: how update one item in gridview? - flutter

I use GridView in my Flutter's app. Size my GridView is 30x4(with different widgets).
I need to update one widget in my gridView. I have two solutions and I need to choose the best.
Update all GridView. It is easy but I think this is not optimal (rebuild the entire grid for one change).
Update one widget. it is more complicated. but I know how to do it. This is a similar example.
what do you advise?

Related

Is building one large better than building small ~75-100 widgets

Consider the case that I have 3 adjacent list view with each list view having a sized widget of some height. Each list view has around 24 child items. I'm trying to scale the widget using onScaleUpdate in GestureDetector.
onScaleUpdate I want to change the height of each child item of all the 3 listviews.
Is rebuilding all child better or should I rebuild the whole widget?
As #Yeasin Sheikh pointed out, using ListView.builder is good because it builds only the needed children (the ones inside the screen and just a few ones outside as precaution). And as to actually answering your question, I'm no Flutter expert, but using ListView.builder I don't think it makes that much difference, Flutter is intelligent enough to solve this by itself.

Now which widgets are right now shown in List

Hello I have a ListView with different Widgets of different height. Now I want to know which of those Widgets are at the moment visible in the ListView. Does anyone has an idea how to do it. I can't use to scroll_to_widget package because it interferes other implementations.
Try using https://pub.dev/packages/visibility_detector maybe you can create a separate list and store true according to index, based on their visibility?

Provide different children if Wrap is multi-line vs single-line

I want to display some widgets in a Wrap, and if the widgets are too many to fit on one row, I want to display different widgets (more compact versions of the normal widgets).
How can I achieve this, without resorting to manual measurements of screen width and children? Is there any built-in way to do this with a Wrap or some other widget?
What if with the compact version, the row is still full. Do you want to display the children in multiline then or wrap them with the next line? If it's the latter, then I think it's best to use Wrap from the beginning.
Another practical way is to make the child adaptable as well, by using FittedBox or make it scrollable horizontally by using SingleChildScrollView or ListView.
There can be other scenarios when it's better to show just 4-5 children that's enough to fit a row. Then have a button allowing user to navigate to a detail screen display all the children in a grid or list.

Use a ListView.builder and wrap widgets dynamically

I try to solve the following problem: I want to have a dynamically generated set of cards widgets which should be layed out horizontal and wrap the line when the card is getting too big:
I was thinking of a ListView.builder but this can either go horizontal or vertical. More, a gridview seems also not the best option as I have no fixed columns or rows. Is there any way in doing so or exists there maybe a widget I am not aware of currently?

Is there any deafult widget like in image or if I need to do it how could that be implemented?

So I am not looking for filters but I am looking for scroll widget. I have tried generating listview items abd getting position of listview to give items ratio but I wasn't able to get any functionality while in certain index position. Any help would be helpfull. Naming of the widget or special widgets that can make me do this etc.
You can use ListView or ListView.builder to do that, but with circle-shaped widgets as the children.
You can check out this tutorial to do the horizontal list. And you can check out this StackOverflow question, to create a circle button. Or instead of a button, you want to use the CircleAvatar (to add an image in it), you can check out this official doc.