Reputation: 6786
I've seen BlocProvider
automatically disposes of the bloc in the flutter_bloc
package. Is this also the case when specifying the bloc/cubit scoped to a single widget?
BlocBuilder<BlocA, BlocAState>(
cubit: blocA, // provide the local cubit instance
builder: (context, state) {
// return widget here based on BlocA's state
}
)
(I seem to be creating multiply instances of my cubit)
Upvotes: 1
Views: 267
Reputation: 3136
BlocBuilder
has nothing to do with dispose of a bloc instance. It is BlocProvider
, that takes care of it automatically. The only case, when you have to dispose of a bloc instance manually, is when you provide it to next widget tree with BlocProvider.value
.
Upvotes: 2