Skip to content
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

Misleading error when providing blocs through ProxyProvider #807

Closed
narcodico opened this issue Jan 26, 2020 · 3 comments
Closed

Misleading error when providing blocs through ProxyProvider #807

narcodico opened this issue Jan 26, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request
Projects

Comments

@narcodico
Copy link
Contributor

Describe the bug
When injecting blocs through ProxyProvider, you get the misleading error of BlocProvider.of() called with a context that does not contain a Bloc of type T, when the actual error is that provider sees a wrong type, being that bloc is a stream. It's not possible to use ListenableProxyProvider since bloc doesn't extend listenable and there's no StreamProxyProvider unfortunately.
Setting Provider.debugCheckInvalidValueType = null; in main() solves the issue, but this should probably be solved in a cleaner way.

https://gist.github.com/RollyPeres/7f181eebda7c33bb7aa2ce8dc5d3cfac

Expected behavior
I'd expect to be able to retrieve without issues any bloc built using ProxyProvider or some flavor of it.

flutter doctor -v

[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.18362.592], locale en-US)
    • Flutter version 1.12.13+hotfix.5 at C:\src\flutter
    • Framework revision 27321ebbad (7 weeks ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0        

 
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.0-rc2)     
    • Android SDK at C:\Users\roland.peres\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.0-rc2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[!] Android Studio (version 3.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[√] VS Code, 64-bit edition (version 1.41.1)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.7.1
@felangel
Copy link
Owner

Hey @RollyPeres 👋
Thanks for opening an issue!

Just to clarify this issue is to improve the error message and not to resolve the issue?

@felangel felangel self-assigned this Jan 26, 2020
@felangel felangel added enhancement New feature or request waiting for response Waiting for follow up labels Jan 26, 2020
@felangel felangel added this to To do in bloc via automation Jan 26, 2020
@narcodico
Copy link
Contributor Author

Hey @felangel , this issue is to improve the error message, but also have a specialized proxy provider which could handle providing a bloc. This is probably something which provider should handle through a StreamProxyProvider.

@felangel felangel removed the waiting for response Waiting for follow up label Jan 28, 2020
@felangel felangel moved this from To do to In progress in bloc Jan 29, 2020
@narcodico narcodico changed the title Misleading error when providing blocs though ProxyProvider Misleading error when providing blocs through ProxyProvider Jan 29, 2020
@felangel
Copy link
Owner

Addressed the misleading error in #816 and published in v3.2.0 of flutter_bloc 👍

bloc automation moved this from In progress to Done Jan 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
bloc
  
Done
Development

No branches or pull requests

2 participants