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

添加english_words依赖后pubspec.yaml报错,无法执行flutter pub get

解决pubspec.yaml添加english_words依赖报错的问题

问题原因

你把english_words: ^4.0.0错误缩进在了sdk: flutter的依赖块里,导致同一个依赖条目出现多个源,触发了"A dependency may only have one source"错误。

修复步骤

  • 打开pubspec.yaml文件
  • 调整english_words的缩进层级,让它和flutter、cupertino_icons处于同一级别
  • 保存文件后重新执行flutter pub get

正确的依赖块示例

dependencies:
  flutter:
    sdk: flutter
  english_words: ^4.0.0
  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.21 23:33:13