尝试在 Flutter 中使用 Animator 时编译错误
Compile error when trying to use Animator in Flutter
编译器消息:
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/animator-0.1.4/lib/animator.dart:457:7: Error: No named parameter with the name 'blocs'.
blocs: [_animatorBloc],
^^^^^ /C:/flutter/.pub-cache/hosted/pub.dartlang.org/states_rebuilder-1.15.0/lib/src/state_with_mixin_builder.dart:142:3: Context: Found this candidate, but the arguments don't match. StateWithMixinBuilder({ ^^^^^^^^^^^^^^^^^^^^^ /C:/flutter/.pub-cache/hosted/pub.dartlang.org/animator-0.1.4/lib/animator.dart:494:27: Error: Method not found: 'StatesRebuilder.addToListeners'.
StatesRebuilder.addToListeners(
^^^^^^^^^^^^^^ /C:/flutter/.pub-cache/hosted/pub.dartlang.org/animator-0.1.4/lib/animator.dart:559:27: Error: Method not found: 'StatesRebuilder.removeFromListeners'.
StatesRebuilder.removeFromListeners(b, widget.name, "$hashCode");
^^^^^^^^^^^^^^^^^^^
通过在 pubsec.yml 文件中添加 statebuilder 包进行修复
states_rebuilder: 1.3.2
看来您使用的是旧版本的 Animator 包。 Animator (2.0.1) 的更新版本有效。最新版本在 builder 函数中需要 3 个参数。 Answered here!
添加states_rebuilder: ^3.2.0
即可解决问题
编译器消息:
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/animator-0.1.4/lib/animator.dart:457:7: Error: No named parameter with the name 'blocs'.
blocs: [_animatorBloc],
^^^^^ /C:/flutter/.pub-cache/hosted/pub.dartlang.org/states_rebuilder-1.15.0/lib/src/state_with_mixin_builder.dart:142:3: Context: Found this candidate, but the arguments don't match. StateWithMixinBuilder({ ^^^^^^^^^^^^^^^^^^^^^ /C:/flutter/.pub-cache/hosted/pub.dartlang.org/animator-0.1.4/lib/animator.dart:494:27: Error: Method not found: 'StatesRebuilder.addToListeners'.
StatesRebuilder.addToListeners(
^^^^^^^^^^^^^^ /C:/flutter/.pub-cache/hosted/pub.dartlang.org/animator-0.1.4/lib/animator.dart:559:27: Error: Method not found: 'StatesRebuilder.removeFromListeners'.
StatesRebuilder.removeFromListeners(b, widget.name, "$hashCode");
^^^^^^^^^^^^^^^^^^^
通过在 pubsec.yml 文件中添加 statebuilder 包进行修复
states_rebuilder: 1.3.2
看来您使用的是旧版本的 Animator 包。 Animator (2.0.1) 的更新版本有效。最新版本在 builder 函数中需要 3 个参数。 Answered here!
添加states_rebuilder: ^3.2.0
即可解决问题