-
-
Notifications
You must be signed in to change notification settings - Fork 515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use parent class of provided class #866
Comments
Correct. This is unsupported. If you wish for your object to be used with BlocProvider<AbstractCubit<int>>( |
Thanks for the quick reply, but simply providing My only idea right now is to provide |
What you're asking is not possible in any case. You'll always have to write extra logic to support both |
Why cannot |
That's not how InheritedWidgets work. They use exact type matching. There's no such thing as specifying a type, but getting a subclass instead. You have to manually expose your provider with said type. No way around it. |
Thank you very much for your explanation |
Description
Hi, I have raised this issue in the bloc package and was delegated to provider (felangel/bloc#4077). I am encountering the following issue, when I provide a certain class and try to use subclasses in a bloc builder an ProviderNotFoundException is thrown.
Consider the following example:
Expected Behavior
The BlocBuilder<AbstractCubit, T> uses the provided IntCubit (since IntCubit is an AbstractCubit).
The text was updated successfully, but these errors were encountered: