Bloc: BlocProvider can't be assigned to the Widget error

Created on 12 Sep 2019  ·  5Comments  ·  Source: felangel/bloc

Describe the bug
I can't run flutter_complex_list example, it gives me this:
The argument type 'BlocProvider' can't be assigned to the parameter type 'Widget'

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'examples/flutter_complex_list'
  2. Click on 'Get Packages'
  3. See error

There's no problem with Get Packages though,

Running "flutter pub get" in flutter_complex_list...                0.4s
exit code 0

Expected behavior
I didn't expect an error because there's the same structure in examples/flutter_firebase_login, BlocProvider in the Scaffold's home parameter.

I've tried to give BlocProvider a type, but that didn't work either.

BlocProvider<ListBloc>

Screenshots
image

*Logs *

Analyzing flutter_complex_list...                                       
No issues found! (ran in 2.6s)

Paste the output of running flutter doctor -v here.

[✓] Flutter (Channel stable, v1.9.1+hotfix.2, on Linux, locale en_US.UTF-8)
    • Flutter version 1.9.1+hotfix.2 at /home/mirkan/development/flutter
    • Framework revision 2d2a1ffec9 (6 days ago), 2019-09-06 18:39:49 -0700
    • Engine revision b863200c37
    • Dart version 2.5.0


[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /home/mirkan/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 28.0.3
    • ANDROID_HOME = /home/mirkan/Android/Sdk
    • ANDROID_SDK_ROOT = /home/mirkan/Android/Sdk
    • Java binary at: /opt/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b16-5323222)
    • All Android licenses accepted.

[!] Android Studio (version 3.4)
    • Android Studio at /opt/android-studio
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b16-5323222)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.2)
    • IntelliJ at /opt/idea-IU-191.7479.19
    • Flutter plugin version 39.0.5
    • Dart plugin version 192.6603.23

[✓] VS Code (version 1.38.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.4.1

[✓] Connected device (1 available)
    • Samsung Galaxy S9 • 192.168.56.106:5555 • android-x86 • Android 9 (API 28)

! Doctor found issues in 1 category.
question

Most helpful comment

Sorry for the delay.
@jorgecoca thanks but I already tried that as you can see in the in my post, and it was the untouched code from the example.

@felangel I didn't clear the cache but I restart my laptop and I don't see the error now.

Aren't these example projects use the relative path for the bloc package? Like ../../packages/flutter_bloc. Is pub cache relevant in this case?

All 5 comments

Aren't you missing the the type inside the BlocProvider declaration? What type of bloc you want to provide?

For example, it could be BlocProvider<ListBloc>(...)

@jorgecoca that shouldn’t be an issue. @mirkancal can you clear your pub cache and make sure you haven't made local changes to BlocProvider?

In addition, can you try restarting VSCode?

@mirkancal I'm unable to reproduce the issue. Can you confirm if you're still seeing it?

Sorry for the delay.
@jorgecoca thanks but I already tried that as you can see in the in my post, and it was the untouched code from the example.

@felangel I didn't clear the cache but I restart my laptop and I don't see the error now.

Aren't these example projects use the relative path for the bloc package? Like ../../packages/flutter_bloc. Is pub cache relevant in this case?

@mirkancal thanks for following up. The dart analyzer must’ve gotten into a weird state. Regarding the pub cache I just wasn’t sure how you had things setup locally 👍

Was this page helpful?
0 / 5 - 0 ratings