Closed tlvenn closed 3 years ago
Can you explain what exactly are you trying to do?
Ideally i would like to be able to simply do onChanged: (username) => context.read(loginCubitProvider).updateUsername(username)
So just to clarify the ask a little bit, I am wondering if it would be possible to split the current flutter_hooks_bloc into 2 packages, like flutter_hooks_bloc
depending on flutter_block & flutter_hooks_riverbloc
depending on flutter_riverpod.
Then depending on if you wish to use riverpod or the provider, it will only import the right BuildContext extension instead of both.
Or maybe it does not have to be 2 packages but 2 entrypoints in the same library so depending on which one you import it will import one extension or the other ?
It is possible, I'll consider it.
@tlvenn I think it is not possible because there are many conflicts between provider
and riverpod
packages.
Both have context.read()
and Provider
class.
One solution is to reexpose providers context.read()
as context.iread()
where the i
refers to InheritedProvider.
I have tested that the submitted PR works.
As pointed out in the PR, turns out the other already existing entrypoint for the library solves this. It probably should be documented 🤣
Hi @kranfix,
Thanks a lot for your work on integrating blocs with riverpod !
At the moment, i am looking at using cubits & blocs with riverpod with the Bloc widgets using the
river
factory (so not using hooks) and there is a little bit of friction on the BuildContext helper methodread
given both riverpod and flutter_block are competing with their extension. I tried to hide the provider extension but for some reason, it did not work so instead i am forced to be explicit with the extension i want to use such asBuildContextX(context).read()
Would it be possible to publish a package that is free of
flutter_bloc
but one that does provide BlocBuilder.river(), BlocListener.river() and BlocConsumer.river() constructors ?