简体   繁体   English

如何在 flutter 创建模板中获取最新版本的 package

[英]How to get latest version of package in flutter create template

I am modifying my default template file from my flutter installation directory here C:\src\flutter\flutter\packages\flutter_tools\templates\app\pubspec.yaml.tmpl我正在从我的 flutter 安装目录C:\src\flutter\flutter\packages\flutter_tools\templates\app\pubspec.yaml.tmpl修改我的默认模板文件

dependencies:
  #omitted
  cupertino_icons: ^0.1.3

  mobx: latest
  flutter_mobx: latest

I am getting this error Invalid version constraint: Could not parse version "latest". Unknown text at "latest".我收到此错误Invalid version constraint: Could not parse version "latest". Unknown text at "latest". Invalid version constraint: Could not parse version "latest". Unknown text at "latest".

How do i get the latest version instead of specifying specific version like ^1.xx我如何获取最新版本而不是指定特定版本,如^1.xx

There is no latest, you have to specify the version number or you can use any :没有最新的,你必须指定版本号或者你可以使用any

any任何

The string any allows any version.字符串 any 允许任何版本。 This is equivalent to an empty version constraint, but is more explicit.这相当于一个空版本约束,但更明确。 Although any is allowed, we don't recommend it.尽管允许任何一种,但我们不推荐这样做。

https://dart.dev/tools/pub/dependencies https://dart.dev/tools/pub/dependencies

To update your dependencies to the latest version you can do the following:要将依赖项更新到最新版本,您可以执行以下操作:

Use pub upgrade to update to the latest package versions that your pubspec allows.使用pub upgrade更新到您的 pubspec 允许的最新 package 版本。 To identify dependencies in your app or package that aren't on the latest stable versions, use pub outdated .要识别您的应用或 package 中不在最新稳定版本上的依赖项,请使用pub outdated

try this after the package that you want the latest在你想要最新的 package 之后试试这个

 http: ^{latest version}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM