【发布时间】:2022-01-02 10:11:58
【问题描述】:
我正在尝试实现来自official docs example 的代码,但它失败了:
...
class _MyHomePageState extends State<MyHomePage> {
late AnimationController controller;
@override
void initState() {
super.initState();
controller = AnimationController(duration: Duration(seconds: 3), vsync: this);
}
...
上面写着:The argument type '_MyHomePageState' can't be assigned to the parameter type 'TickerProvider'.
所以,VSCode 高亮显示vsync: this 参数。
我有最新版本的 Flutter:
Flutter 2.5.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 18116933e7 (6 weeks ago) • 2021-10-15 10:46:35 -0700
Engine • revision d3ea636dc5
Tools • Dart 2.14.4
为什么会出现此错误以及如何在不降级 SDK 版本的情况下解决此问题?
【问题讨论】:
标签: flutter dart flutter-animation