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

Flutter Web应用运行报错:chips_choice_null_safety参数缺失错误

解决Flutter Web运行时chips_choice_null_safety包的参数错误

问题根源

报错直接点明了问题:AlwaysStoppedAnimation<Color>()构造函数必须传入一个Color类型的位置参数,但你使用的chips_choice_null_safety-2.0.6版本代码里未传值,这是包版本与当前Flutter SDK不兼容导致的。

两种解决办法

  • 优先升级/替换依赖包:

    1. 打开pubspec.yaml,将chips_choice_null_safety替换为官方维护的新版包(比如原包chips_choice已支持空安全,更新更及时),或查找该包的最新兼容版本。
    2. 执行flutter pub get重新拉取依赖。
  • 临时修改包源码救急(不推荐):

    1. 找到报错路径对应的文件:../../.pub-cache/hosted/pub.dev/chips_choice_null_safety-2.0.6/lib/src/widget.dart
    2. 定位到第506行,将AlwaysStoppedAnimation<Color>()修改为AlwaysStoppedAnimation<Color>(Theme.of(context).primaryColor)(或根据组件上下文传入合适的颜色值)。
    3. 保存后重新执行flutter run即可。

⚠️ 注意:修改本地缓存的包源码仅为临时方案,后续执行flutter pub get会覆盖修改内容,因此优先推荐第一种解决方式。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.01 09:52:07