Refreshing only those rows DataTable or ListView that are affected by changes in Flutter - flutter

I have a DataTable (or ListView) and use bloc pattern, for example, for state management. Each row has an action which deletes it. Deletion should be done first on the server and I wish to update DataTable to only remove this row by not refreshing the whole DataTable (or ListView). All I can do right now is to only refresh the whole DataTable, which destroys UX.
What would be the best approach?
ALso, it would be acceptable too if anyone can recommend a plugin that solves this problem.

Related

Animate Flutter DataTable

I'm relatively new to Flutter and am now trying to animate some of my widgets.
I'm currently struggling to animate my DataTable. I have a dynamically built DataTable that has to be able to add and delete values. I'm trying to animate insertions and deletions of a new Column. Right now this is happening instantaneously.
I've seen that Flutter offers a lot of animated widgets out of the box already. For example AnimatedList which would probably be perfect. Unfortunately, I haven't found any alternatives like that for the DataTable widget.
How would one go on to animate something like this?

Flutter Listview items not rendering

What I do is fetching items from Firebase then saving them in a list and then I display them in a ListView. The Problem that I have now is that I check if the list has Items and if so it displays my ListView with the Items and if there are no items it displays a Text but even but even if there are items the text gets displayed but after pressing hot reload the items get shown.
My guess was that there is a Problem with the State of the Widgets overall because stuff like SetState has no effect or a Refresh Indicator
Is there a reason why the StreamBuilder is following your masterListStart().asStream as opposed to the masterList stream? I'm not saying it's wrong, its just not immediately obvious.
Either way, it's not rebuilding automatically because the only part of your displayStory method that is reactive to the stream doesn't get built until after the non empty list condition is met. Without implementing a reactive state management solution there's nothing in your code that automatically notifies any listeners that the state of the storysList has changed, which means nothing is triggering a rebuild. Which is why you have to hot reload to see the changes.
Without me getting too deep into your code, try returning the StreamBuilder at the top level of the displayStory method and putting all the conditionals inside its its builder method.

Flutter: A way to append incoming data to ListView instead of rebuilding entire thing?

Summary: Planning to show readonly data array in a ListView widget. Data comes in using a Provider. Is it possible to not rebuild the entire ListView every time, and just append a new Tile to it?
Details: The ListView data set coming in is similar to log entries--it's static and only the last item is coming in. Rebuilding the entire ListView every time seems a bit wasteful. Is it possible to have it in such a way that it would append new Tile widgets on incoming data instead?
Please provide some sample code or your code. For now from this question I'll suggest you to take a look on AnimatedList.

How to prevent Stateful Widget stored in List to be disposed?

Let me start by explaining the problem. I have several buttons which are created based on data I'm getting from a server. On each button click I need to create and display a widget which will present me some data (this widget is also built dynamically). The state of this widget has to be preserved during the lifetime of the app. (for example if I click another button and show a different widget, I need to be able to click on the first button and show the first widget in its preserved state). Number of buttons can also be changed during the app lifetime.
I tried using IndexedStack to achieve this, but when the number of buttons is changed I need to add "pages" to IndexedStack, therefore I need to recreate a new IndexedStack which will have some of my old widgets, so I pull widgets from a List or create new ones if needed. This works great, except Flutter calls dispose() method on my widgets which are stored in the list. I tried using the AutomaticKeepAliveClientMixIn but it didn't help.
I'm guessing this has something to do that the widgets get detached from the parent, but when I reattach them to new parent (new Indexed stack) Flutter doesn't figure out this properly.
Any ideas?
Try to store data to local storage or sqlite for persistence data.

What's the alternative to using a StreamBuilder inside of a column or row?

I am trying to build a page that shows a hierarchy of data. The top of the page is built by passed in data. But the dependencies need to query a db and post their results.
For example Team A has players. Under the heading of team A I want to show a list of players on the team. But if I try to add a streamBuilder as a part of screen, I get all sorts of nasty message about some part of the build process not having a height. Its seems that streamBuilder only works as the highest level widget.
So there must be an alternative for building those widgets, can anyone point me to an example of that being used?
An alternative to a StreamBuilder is FutureBuilder - where you can use a Future callback instead of a Stream to fetch a data snapshot for the children Widgets inside it.
However, if you're getting "unbounded height" errors, this is usually thrown by children Widgets with undefined height inside a ListView or Scrollable widget. You'll be needing to set a height for those List items to fix that error.