【问题标题】:Unable to add local package in pubspec.yaml无法在 pubspec.yaml 中添加本地包
【发布时间】:2021-03-26 19:55:22
【问题描述】:

尝试在flutter中添加本地包但出现错误:

Error on line 42, column 5 of pubspec.yaml: Invalid version constraint: Could not parse version "path:../hello/". Unknown text at "path:../hello/".

   ╷
42 │     path:../hello/
   │     ^^^^^^^^^^^^^^
   ╵
pub get failed (65;    ╵)


pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter  

  cupertino_icons: ^1.0.0

  hello: 
    path:../hello/

我尝试使用 tabspace 缩进路径,但没有成功。

【问题讨论】:

  • 你是真的用path:../hello/还是只是一个例子?
  • 你好是插件的名字

标签: flutter dart flutter-dependencies


【解决方案1】:

pubspec.yaml 对丢失的空格真的很无情。如果你已经确认本地包路径正确,那么下面这个肯定是错误的:

hello: 
  path:../hello/

因为您在path: 之后缺少

将其更改为以下内容:

hello: 
  path: ../hello/

因此pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter  

  cupertino_icons: ^1.0.0

  hello: 
    path: ../hello/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-04
    • 1970-01-01
    • 1970-01-01
    • 2019-05-13
    • 2022-08-17
    • 2011-06-29
    相关资源
    最近更新 更多