Bloc v8.0.0 is out!

An overview of the Bloc v8.0.0 release

November 18, 2021
November 18, 2021
updated on
March 13, 2023
Guest Contributor


That latest stable version of the Bloc library is out: Bloc v8.0.0! Most notably, v8.0.0 removes the deprecated mapEventToState API in favor of on<Event>, which was introduced in v7.2.0. This is a breaking change, so while things were backwards compatible with ^7.2.0, upgrading to v8.0.0 will require that all blocs are refactored to use the APIs. If you haven’t already, we highly recommend waiting to upgrade to v8.0.0 until all blocs have been refactored to use the new APIs. You can do this at your own pace using ^7.2.0.

Additional changes

In addition, v8.0.0 introduces a new BlocOverrides API which enables specifying BlocObserver, EventTransformer, and HydratedStorage overrides that are scoped to a particular zone. With the previous implementation, you were constrained to having a single, global observer/event transformer/storage. The new API enables those overrides to be scoped and for multiple implementations of these overrides to exist within a single application.

Before v8.0.0

void main() { = CustomBlocObserver();
  Bloc.transformer = customEventTransformer();
  // ...

After v8.0.0

void main() {
    () {
      // ...
    blocObserver: CustomBlocObserver(),
    eventTransformer: customEventTransformer(),

For more context regarding the BlocOverrides API refer to this pull request.

This upgrade also brings a number of fixes and improvements, including better error handling and reporting via the addError API. The full list of changes can be found here.

What’s next

We’re experimenting with Flutter APIs to expose the BlocOverrides API within the context of the widget tree. The goal of this exploration is to make it even easier to scope instances of BlocObservers, EventTransformers, and Storage to different parts of the Flutter application. A common use case is using an encrypted storage implementation when the user is authenticated and an unencrypted implementation when there is no user authenticated within the context of hydrated_bloc. Look out for a proposal soon regarding what these changes could look like.

View the full migration guide for bloc v8.0.0

For more on migrating your blocs, check out our other blogs:

Scarlett Wardrop contributed to this article.

More Stories