Bloc v8.0.0 is out!

An overview of the Bloc v8.0.0 release

Felix Angelov
Felix Angelov
Felix Angelov
November 18, 2021
3min
News
Bloc v8.0.0 is out!

Overview

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() {
Bloc.observer = CustomBlocObserver();
Bloc.transformer = customEventTransformer();

// ...
}

After v8.0.0


void main() {
BlocOverrides.runZoned(
() {
// ...
},
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.

Name of the heading

Category
Architecture
Best Practices
Open Source
Share

Insights from Our Experts

View All Insights
Creating Your First Dart Analyzer Plugin with the New Plugin System

Creating Your First Dart Analyzer Plugin with the New Plugin System

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

Óscar Martín
Óscar Martín
December 1, 2025
Creating Your First Dart Analyzer Plugin with the New Plugin System
How We Efficiently Onboard Engineers at Very Good Ventures

How We Efficiently Onboard Engineers at Very Good Ventures

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

Marcus Twichel
Marcus Twichel
November 20, 2025
How We Efficiently Onboard Engineers at Very Good Ventures
From Code to Community: How puf Inspires More People to Build More Apps

From Code to Community: How puf Inspires More People to Build More Apps

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

VGV Team
VGV Team
November 19, 2025
From Code to Community: How puf Inspires More People to Build More Apps