Flutter mainstream_extended - StreamBuilder with batteries included


The default StreamBuilder in Flutter is amazing and helps with Widget construction really well. If used as is, StreamBuilder requires basic plumbing to handle states that can have default behaviors.

mainstream_extended solves this by providing widgets and handlers for most common result data scenarios.

You can get more information at https://pub.dev/packages/mainstream_extended

These cases are:

  • Loading data
  • Empty data
  • Error condition
  • Data available

We might need to do some other actions in addition to simply constructing widgets. Muddling them with the builder is a code smell, hence additional handlers are provided to perform non-widget building actions.

mainstream_extended is a drop-in replacement for StreamBuilder and avoids all of the pitfalls.


/images/streambuilder-before-code.png Courtesy: https://medium.com/@greg.perry/decode-streambuilder-e60948629d8e

After: /images/streambuilder-after-code.png

As you can notice, most of the plumbing and error handling is now managed by mainstream_extended. You can of course customize it as you wish.

Head over to https://pub.dev/packages/mainstream_extended and get started. Please post any issues/feedback on Github.

Join my newsletter
I'll send you my latest blog posts by email. Also, you'll be the first to hear about new things I'm working on.