Skip to content

Upgrading flutter_bloc 6 to 7

Breaking6.1.3 → 7.3.3Breaking14New3Changed12Fixed4Other6

BreakingUpgrade verdict

12 breaking changes.

  • If you passed a cubit to these widgets using the named `cubit` argument, you now need to use `bloc` instead.
  • Code that read a repository from the build context via `context.repository` no longer works.
  • The package no longer depends on Flutter, which can affect projects that relied on that transitive dependency.
  • Access storage through HydratedBloc.storage instead of HydratedCubit.storage.
Top 3 of 12 that need code or config changes

Dart SDK requirement changed in 7.0.1: >=2.6.0 <3.0.0 → >=2.12.0 <3.0.0.

Breaking12
Renames the cubit parameter to bloc in BlocListener, BlocBuilder, and BlocConsumer.
BlocListenerBlocBuilderBlocConsumercubitbloc
Removes the deprecated context.repository extension.
context.repository
Removes the flutter dependency.
flutter
Removes HydratedCubit.storage in favor of HydratedBloc.storage.
HydratedCubit.storageHydratedBloc.storage
Removes the context.bloc extension.
context.bloc
Renames the cubit parameter in BlocListener to value.
BlocListenercubitvalue
Renames the cubit parameter in BlocBuilder to value.
BlocBuildercubitvalue
Renames the cubit parameter in BlocConsumer to value.
BlocConsumercubitvalue
Removes the dependency on package:provider.
package:provider
Opts into null safety.
Requires storageDirectory when calling HydratedStorage.build.
HydratedStorage.buildstorageDirectory
Reverts the changes from version 7.0.0-dev.1.