Skip to content

Upgrading flutter_bloc 5 to 6

Breaking5.0.1 → 6.1.3Breaking5Deprecated2New5Changed6Fixed5Other9

BreakingUpgrade verdict

5 breaking changes.

  • If you pass a cubit to BlocBuilder, the argument is now called cubit instead of bloc.
  • If you pass a cubit to BlocListener, the argument is now called cubit instead of bloc.
  • If you pass a cubit to BlocConsumer, the argument is now called cubit instead of bloc.
  • This version needs the newer 6.x core bloc package to work.
Top 5 of 7 that need code or config changes
Breaking5
Renames the BlocBuilder bloc parameter to cubit for cubit interop.
BlocBuilder
Renames the BlocListener bloc parameter to cubit for cubit interop.
BlocListener
Renames the BlocConsumer bloc parameter to cubit for cubit interop.
BlocConsumer
Upgrades the required bloc dependency to ^6.0.0.
Upgrades the bloc dependency to ^6.0.0-dev.1.
Deprecated2
Deprecates context.bloc in favor of context.read and context.watch.
context.bloccontext.readcontext.watch
Deprecates context.repository in favor of context.read and context.watch.
context.repositorycontext.readcontext.watch