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
Maybe you have surrendered to the convenience 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.
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:
the usage of inheritFromWidgetOfExactType vs ancestorInheritedElementForWidgetOfExactType,
the implementation of updateShouldNotify.
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.