At long last, v1.0.0 is here! It’s been just over one year since the bloc package was released into the wild. Since then the community has grown tremendously and has played a significant role in shaping the library.
Before delving into what’s changed, I want to give a big thank you to everyone who has contributed whether it be through opening issues, improving documentation, adding feature requests, or simply reaching out on gitter or via email with feedback. I couldn’t have made it this far without your help!
Now let’s jump into what’s changed!
Alignment with the Core Dart Stream/Sink API
What started off as a rename request from Bernardo Ferrari turned into a much larger discussion of the core bloc api (full discussion). Thanks to the feedback of many members of the community including Honza Bittner, Jonathan White, Audrius Karosevicius, Remi Rousselet, and Brian Egan we decided to make some adjustments to the bloc api in order to align with the core stream primitives and deliver a more consistent and familiar developer experience.
Bloc as a Stream<State>
In v1.0.0 of the bloc library, all blocs are
Streams. That means we no longer need
Stream<State> get state. Developers can now listen to a bloc’s state stream directly from the bloc.
This also enabled us to repurpose the bloc
state property to return the value of the state, removing the need for a
These changes were done in hopes of eliminating any previous confusion of the difference between
bloc.currentState. Working with a bloc’s state stream should now feel very intuitive, especially to those coming from
Bloc as a Sink<Event>
In v1.0.0 of the bloc library, all blocs are now
Sinks. This means we can start using the traditional
add sink api in order notify the bloc of a new event instead of
dispose was deprecated in favor of
Not only do these changes align the bloc api with existing standards, but we also get the added benefit of the dartanalyzer showing warnings if we forget to call
close on our blocs (
BlocProvider still does this automatically).
v1.0.0 of the bloc library also includes a new package: bloc_test. This package is still in the early stages, but will be home to a suite of testing helpers specifically designed for the bloc library.
Currently, the package allows us to easily stub a bloc’s state stream via
whenListen (shoutout to Brian Egan for the suggestion).
Expect additional testing helpers to be including in the coming weeks!
New Domain and Publisher
The bloc library official documentation can now be found at https://bloclibrary.dev!
*https://felangel.github.io/bloc will redirect automatically.
Now on Github Sponsors 💖
I’m very lucky to have just been accepted into the Github Sponsors beta program. So if you like the bloc library, or any of my other open source projects, consider sponsoring me (tiers start as low as $2 / month) to show your support. 🙏
You can also support me by ⭐️ the repository, or 👏 for this story, thanks!