我在扑朔迷离地实现BLoC时遇到了麻烦,我遵循了本教程:https://github.com/ResoCoder/youtube-search-flutter-bloc
但是我收到以下无法调试的编译器消息:
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
我正在使用:
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)
关于如何解决此错误的任何想法? 谢谢!
答案 0 :(得分:3)
我发现了问题,rxdart:0.21.0已被重构并破坏了块0.8.4,为了解决此问题,请添加rxdart:0.20.0作为pubspec.loc的依赖项。
答案 1 :(得分:2)
我能够使用最新的flutter_bloc依赖项(目前为flutter_bloc:^ 0.8.0)来解决此问题。
答案 2 :(得分:0)
使用最新版本:
rxdart: ^0.24.1
bloc: ^4.0.0
flutter_bloc: ^4.0.0
不要忘记:
flutter clean // in case of any error
flutter pub get
如果您更新bloc
,则必须更新问题flutter_bloc
。那是因为flutter_bloc
取决于bloc
。
还请注意,您不能使用最新的rxdart
,因为bloc
取决于rxdart >=0.18.1 <0.21.0
,这实际上很痛苦。