5

I'm having trouble implementing BLoC in flutter, i followed this tutorial: https://github.com/ResoCoder/youtube-search-flutter-bloc

But i get the following compiler message that i haven't been able to debug:

Compiler message:
file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/bloc-0.8.4/lib/src/bloc.dart:24:44: Error: No named parameter with the name 'seedValue'.
_stateSubject = BehaviorSubject<State>(seedValue: initialState);
                                       ^^^^^^^^^
file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/rxdart-0.21.0/lib/src/subjects/behavior_subject.dart:49:11: Context: Found this candidate, but the arguments don't match.
factory BehaviorSubject({
        ^
Compiler failed on /home/rafa/AndroidStudioProjects/news/lib/main.dart
Finished with error: Gradle task assembleDebug failed with exit code 1

Im using:

Flutter 1.2.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 8661d8aecd (12 days ago) • 2019-02-14 19:19:53 -0800
Engine • revision 3757390fa4
Tools • Dart 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)

Any ideas on how to fix this error? Thanks!

Rafa He So
  • 473
  • 3
  • 12

3 Answers3

7

I found the issue, rxdart: 0.21.0 has been refactored and breaks bloc 0.8.4, in order to fix this problem add rxdart: 0.20.0 as a dependency to pubspec.loc

Rafa He So
  • 473
  • 3
  • 12
  • Thank you. May I ask how you found this out? – larryq Mar 18 '19 at 05:47
  • It was a painful debugging... but when i saw that the error was between the calls from third party packages, in particular the rxdart package i updated it and this fixed my problem... – Rafa He So Sep 05 '19 at 13:49
5

I was able to fix this by using the most recent flutter_bloc dependency, which is currently flutter_bloc: ^0.8.0.

0

Use latest versions:

  rxdart: ^0.24.1
  bloc: ^4.0.0
  flutter_bloc: ^4.0.0

Dont forget to:

flutter clean // in case of any error
flutter pub get

Issue is bloc have to be updated if you update flutter_bloc. That because flutter_bloc depends on bloc.

Also note that you cannot use latest rxdart because bloc depends on rxdart >=0.18.1 <0.21.0 which is actually painful.

Blasanka
  • 21,001
  • 12
  • 102
  • 104