Bloc: BloC instance for each list view item

Created on 30 Dec 2019  路  2Comments  路  Source: felangel/bloc

Hey Everyone!

Is it a good idea to instantiate a BloC for each ListView item? And if so, is having BlocBuilder with BlocProvider together to handle the disposal of blocs as the list view recycles, is a good idea as well?

I'm doing this because I need the ListView Item (Individually) to react upon a state that can take time per list view item.

Such as I want to display a loading indicator until the request completes, and handle cases such as failure due to internet connection, etc.

The reason I don't want to do this in a single BloC is that the states (Items Loaded, Items Loading..) will be tightly coupled with the action logic (Item Updated, Item Updating, or Item Failed Updating) that I want to separate for each BloC.

The UI Skeleton,

-- ListViewTile (BlocA: Item1)
--- Button
.
.
-- ListViewTile (BlocA: ItemN)
--- Button
question

Most helpful comment

Hi @mustafa96m 馃憢
Thanks for opening an issue!

Have you taken a look at the complex list example?

All 2 comments

Hi @mustafa96m 馃憢
Thanks for opening an issue!

Have you taken a look at the complex list example?

Hi Felix,

Thanks for sharing this example. This is exactly what I was looking for!

I mostly learned the BloC pattern from the rest of the examples you authored, yet I don't know how I missed this one! Sorry for disturbing you and Happy Holidays.

Was this page helpful?
0 / 5 - 0 ratings