flutter_bloc_list_manager
flutter_bloc_list_manager copied to clipboard
Consider converting the source bloc to a repository
It's likely one will be creating a source bloc that is only ever used when creating a ListManager
. It may be more efficient to simply supply a repository to the ListManager
instead. This would have the added benefit of making the generic types less verbose, and the surrounding state checking less involved.
This is a great package!
I'm getting tired of building custom blocs with a lot of boiler plate over and over again for something as simple as CRUD.
flutter_form_bloc is really great for the CRUD part and this could be a great list counterpart.
Have you seen flutter_bloc_patterns? https://pub.dev/packages?q=flutter_bloc_patterns
Also similar architecture, using repositories though.
I'm thinking of combining the two approaches and also perhaps proving a DataTableSource adapter out of the box, paging and perhaps even repository generation via openapi-generator that now supports dart-dio
Thanks @ayushin !
I actually found the flutter_bloc_patterns
package while I was working through creating this package. They do have some blocs for filtering your list, but nothing that makes it easy to manage the data backing your filtering UI and nothing that lets you also narrow results from a search query on top of that.
I actually haven't seen flutter_form_bloc
before, I'll definitely check that out!
I've been playing with different approaches for a while, but in reality if you want to load data from an api endpoint (i.e. repository) you only need a Page object that would contain offset, limit and a total number of objects available (count) along with the actual data inside of the page and a Filter, that also has limit and offset fields inside of it and then a some events to manipulate the filter that would result in re-loading of the data. If you don't want to use a filter you just use the bloc with null filter and if you don't want to use paging you just use it with offset =0 limit = null
But if you want to add sorting on top of that you are really leaning towards DataTableSource approach that is aware about the structure of your rows.
What other functionality are you thinking about to facilitate the filtering ui?
I've just published my take on generic list_bloc in pure dart suitable to be used in conjunction with https://openapi-generator.tech/docs/generators/dart-dio/
I'm using simple repositories and built_value
filters that seem to be very effective.
I think it would be great to combine it with the view manager you are building.
link: https://pub.dev/packages/list_bloc
Extra time is in short supply these days, but I'll be sure to check out that package!
As far as functionality for filtering, that's really the main intent of the package as it stands. Generating all of the options based on the available items, mechanisms to choose which options should be actively filtering, then automatically applying all of that to your list of items.
Specifically UI related, I do hope to create some very basic widgets bundled into the package (similar to ones found in the examples): #3