Flutter error while triying to implement BLoC from youtube-search-tutorial
Asked Answered
H

3

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!

Herewith answered 26/2, 2019 at 17:42 Comment(0)
H
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

Herewith answered 26/2, 2019 at 18:57 Comment(2)
Thank you. May I ask how you found this out?Nursling
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...Herewith
A
5

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

Attending answered 23/3, 2019 at 9:25 Comment(0)
R
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.

Repertory answered 23/5, 2020 at 16:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.