You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调试Flutter应用时出现'vsync'无命名参数错误求助

Flutter编译错误:No named parameter with the name 'vsync'

执行Gradle任务assembleDebug时触发如下报错:

Running Gradle task 'assembleDebug'...
../../../AppData/Local/Pub/Cache/hosted/pub.dev/stacked-3.2.1/lib/src/view_models/ui/skeleton_loader.dart:105:19: Error: No named parameter with the name 'vsync'.
                  vsync: this,
                  ^^^^^
/C:/flutter/packages/flutter/lib/src/widgets/animated_size.dart:28:9: Context: Found this candidate, but the arguments don't match.
  const AnimatedSize({
        ^^^^^^^^^^^^
Target kernel_snapshot failed: Exception

错误原因

stacked 3.2.1版本的skeleton_loader.dart第105行,向Flutter的AnimatedSize构造函数传递了vsync参数,但新版本Flutter已经移除了该参数,导致参数不匹配,最终编译任务失败。

解决办法

  • 升级stacked包:在项目的pubspec.yaml文件中,将stacked的版本更新为兼容当前Flutter版本的最新版(例如stacked: ^[最新兼容版本号]),执行flutter pub get拉取新依赖。
  • 降级Flutter版本:如果暂时不想升级stacked,可通过flutter downgrade [适配版本号]将Flutter降级到仍支持AnimatedSize的vsync参数的旧版本(如Flutter 3.7及更早版本)。
  • 临时修改缓存代码:找到报错路径下的skeleton_loader.dart,删除第105行的vsync: this,参数。注意此方法在重新执行flutter pub get后会失效,仅作临时应急用。

内容的提问来源于stack exchange,提问作者oyeleke Blessing

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 06:35:03