Question [hydrated_bloc] sophisticated example #2392
Comments
|
Hi @II11II The latest version of the weather app is using hydrated_bloc to cache the weather information so that it is available offline. Is there something in particular that you're having trouble achieving? I think the weather app should provide a good overview of how you could use hydrated_bloc to accomplish what you're asking for. Thanks |
|
Hi @felangel Yes, there are some trouble to save nested data using hydrated bloc. The example of dilemma i provided above. |
|
Here example: |
Is there a code example? |
Hi @kovacbb Actually, I could not write good code for state and bloc and wrote using streams + sqflite it. So there is no code I can provide where the hydrated bloc is used, for that, I asked for example for such kind of feature using hydrated bloc |
|
@felangel What if I have multiple states (that extends from a parent state) with different properties. Can I use hydrated_bloc in that case, or I have to stick to the parent state and wrap all the properties inside that? |
You can still use HydratedBloc in that case. You just need to adjust the toJson and fromJson implementations to check the type of the state and perform the correct (de)serialization. |
|
In case @II11II or anyone else may be helped by this:
this way i can use one-liners for |
Firstly, I would like to thank the creator @felangel and contributors to these packages.
I would like to ask to add one sophisticated example usage of hydrated bloc according to the real problem( Manage to save categories to local database using hydrated bloc)
As known, nowadays numerous applications demands complicated feature (such as saving categories and its subcategories locally). Adding this kind of example will help developers to use hydrated bloc correctly.
Real-world API example:
"some_url/category/getRoot" will return this kind of response
"some_url/category/${id}" will return subcategories of that catgories
After getting these details, it should be saved locally using a hydrated bloc.
It would be nice if you add example which shows how to properly use Hydrated bloc
The text was updated successfully, but these errors were encountered: