flutter, provider and data tables - flutter

I'm looking for a way to create a data table with flutter driven by the provider package. But whatever I try with Table() or DataTable() I can't make it happen to connect to a ChangeNotificationProvider.
Both TableRow and DataRaw are not widgets I can connect to the provider.
I want to achieve a way to the each object from my business model connected to a row in the table.
When a value is changing I don't want to rebuild the whole table (that I could achieve with DateTable). I want to update only the relevant cells and keep the scroll position.
Any hint ? All the samples I could find or build are not really useful for reality.

Related

Flutter RiverPod - loading data from multiple repositories required for a form

A RiverPod newbie question... I am looking for design guidance on how to use RiverPod providers for a Flutter form where I need to load....
The data entity being updated in the form
A list of another entities that are used as the data source for a drop down selector
A second list of a third entity that again will be used to populate a drop down selector
Should I design this around a composite state class that includes data for all three sources?
Or should there be a separate FutureProvider for each data source? If so, how would I combine the three into one 'Future' ?

Flutter + Provider + Sqflite: Aggregated data state management

Background
Say I have 30 sqlite db entities with their corresponding individual dart class models. Of those, many are aggregated and shown in several widgets of the app. CRUD operations should re-run the corresponding aggregation and update the respective ui/widgets that consume the data.
Current state
Today I read from the db every time I build the widgets.
Need
How can I have generic provider/listener for the aggregations as well as the entities without creating one provider for each entity and aggregated view? It should be able to resolve which widgets to update.
I want to have a state management layer, with a dependency tree, as opposed to reading from the db every time the widget is built.
The way I understand it is that you want to have state management with the provider package, but you don't want to create types that extend ChangeNotifier to manage your data models.
You gonna have to extend ChnageNotifier in order to call notifyListeners where needed to update your UI. So at least create one type that extends ChangeNotifier, and have it manage all of your data objects. Generally, this is not a good as there is no reason not to create a type per each model.

How do you map the same entity to identical tables using Entity Framework 4.0?

In my conceptual model I have a 'Box' that can contain 'x' number of widgets. Some of the widgets can be archived and are accessed infrequently. A box can contain one or more widgets. To support maximum database performance I want to use two identical database tables; one for normal widgets and one for archived widgets. I don't want the Box entity to have two different collections of widgets, eg IList<ArchiveWidget> & IList<Widget>, just one that contains both archived and active widgets.
How can I map the 'Box' entity to the 'Widget' entity that uses the archive and active tables at the same time?
There is on way you could try to solve this: Create a view that is a union of NewWidget and ArchivedWidget. This would work for reading data.
Another alternative is to go into the edmx file and try an fix it there. But I do not think that this is possible, since if you create a new widget and say save, EF would not know which table to put it in.
You could generate the EF model with the two types, then move the type definition into a base class, which both of the widget inherit from. I have not tried this, therefore not sure if it will work.

GWT SelectionModel in Cell widgets - setSelected by key?

Is there any way to select items by key with GWT's selection model? setSelected only seems to take an object from which it can derive a Key, but using that function means I have to construct a sort of fake object. If my KeyProvider ever changes, that part of my code could break without my knowledge, so I'd like to just construct a key directly somehow.
"I have a celltable that shows a list of entities. When the user creates a new entity, I want to refresh the list (which will have the new entity) and automatically select the new entity."
I have this behaviour in my app as well. I manipulate the ListDataProvider. I find the item or items of interest, move them to the top of the list, call the selection model to set them to selected, and refresh the attached data displays. I use the same approach for picklist tables I use when I want to pre-select the default choices for the user (usually based on the item that is spawning the picklist) and move them to the top of the list. I spent a lot of time looking through the selection model api and there is nothing for keys. I suspect that the GWT designers figured it wasn't necessary, since you have access to the ListDataProvider. Find the items of interest there and then call the selection model select method on those specific objects. I can see their point -- replicating the functionality in ListDataProvider and SelectionModel would blur the distinction between the two classes, and perhaps limit the reusability of the SelectionModel construction in other (future) data structures that don't use keys.

How do I store arbitrary data in a GWT widget?

I'm creating a table using GWT, and in certain cells of the table, I want to store a piece of data in that cell's Widget for use in the Widget's handler callback. I can't seem to find an API method such as widget.setData(key, value);. How do I (or can I) accomplish this?
You could subclass the widget you want - and add the appropriate members and get/set methods.
The table example may be better served by storing the object inside a button instance, i.e an 'Edit' button.
Alternatively, you could maintain a map of objects that relate to each row index. This would save creating a lot of unnecessary widgets.