Hey folks!
I just published a new package to be used with Bloc, called bloc_superpowers, with full docs at in https://blocsuperpowers.org/
I do have my own state management package, AsyncRedux, which I modestly think is the GOAT
, but since Bloc has around 100x more users, I decided to port some of its great features to Bloc, and that turned into Bloc Superpowers.
This new package also helps developing with AI, and I plan to release AI-ready “Skills” for it soon.
Some of the features of this new package:
context.isWaiting(): Show loading indicators when Cubits load. No explicit loading states needed.context.isFailed(): Show error messages when a Cubit fails. No explicit error states needed.UserException: A Cubit that fails can now just throw exceptions.UserExceptionDialog: Shows an error dialog when a Cubit throws an exception.UserExceptionToast: Shows a toast when a Cubit throws an exception.retry: Easily retry failed Cubit methods.checkInternet: Check for internet connectivity before executing Cubit methods.nonReentrant: Prevent Cubit methods from being called simultaneously.sequential: Queue Cubit method calls and process them one after another, in order.fresh: Treat Cubit methods as fresh for some time. Prevent reloading data too often.debounce: Debounce Cubit method calls to avoid rapid successive calls.throttle: Throttle Cubit method calls to limit how often they can be called.catchError: Suppress errors, rethrow them, or wrap them in user-friendly exceptions.MixConfig: Create reusable configurations for themixfunction.MixPreset: Create your own reusablemixfunctions.optimisticCommand: Apply a blocking optimistic state change immediately, run the command on the server, optionally rolling back and reloading.optimisticSync: Update the UI immediately and send a value to the server, with eventual consistency between UI and server.optimisticSyncWithPush: Similar to optimisticSync, but resilient to server-pushed updates that may modify the same state.Effect: Allows Cubits to emit one-time effects to the UI, such as navigation events, dialogs, toasts. ReplacesBlocListener.EffectQueue: Allows Cubits to emit queued one-time effects to the UI, ensuring they are shown one after the other.globalCatchError: Set a global error handler for all mix calls in your app. Log errors, show friendly messages, or convert API errors to user exceptions in one place.observer: Set up a global observer to track all mix calls for performance tracking, analytics, debugging, and monitoring.
One last note: when I get the time, I also plan to release a similar package that works with state management solutions other than Bloc.
If you’re using Bloc, I’d love to hear what you think. Would Bloc Superpowers be useful in your projects?