Roberto Huertas
Roberto Huertas A Barcelona-based web & mobile developer wandering through cyberspace.
Organizer of bcn_rust. Currently working at Telefonica Alpha.

Generic BloC Provider

Generic BloC Provider

If you’re using the BloC pattern to manage the state of your Flutter applications probably you’re tired of writing again and again your BloC providers. I’ve just published a simple package called Generic BloC Provider that will help you with that.

Thank God we have generics!

If you’re not new to the BloC pattern probably you have also suffered the boilerplate associated to the BloC providers.

Maybe you have surrendered to the comodity of copy & paste and you don’t care about this, but if you’re like me and you hate having repetitive code probably you have been creating your own generic implementation.

It’s something easy and it doesn’t require a lot of Flutter knowledge to build, but again, whenever you have to start a new project you may find yourself with your old friend copy & paste copying your generic implementation from project to project, and maybe, improving it and mutating it along the way.

And that’s a complete waste of time.

That’s why I decided to publish a new package doing precisely that, a generic implementation of a BloC provider naively called generic_bloc_provider.

Learning something new while at it

While I was building this package I also learnt about how to automate the process of analyzing, testing and publishing a Flutter package using Travis CI.

In case you want to learn more about it, please check out my previous post in my blog or in medium. :grinning:

Some extra features

You can see how to use the package in the Github’s repo or in Pub Dartlang.

I’ve tried to let the user of the package customize some of the behaviors, namely:

  1. the usage of inheritFromWidgetOfExactType vs ancestorInheritedElementForWidgetOfExactType,

  2. the implementation of updateShouldNotify.

Contribute

I hope you find it useful and, of course, feel free to open an issue or, better, a PR with some improvement in the Github’s repo.

Enjoy!

comments powered by Disqus