如何在macos中安装用于颤振和渡槽的两种不同版本的飞镖



目前我安装了带有颤振的飞镖,版本如下:

Flutter 1.23.0-18.1.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 198df796aa (2 weeks ago) • 2020-10-15 12:04:33 -0700
Engine • revision 1d12d82d9c
Tools • Dart 2.11.0 (build 2.11.0-213.1.beta)

我主要从事移动应用程序前端开发,因此这个设置对我来说很好

但为了后端数据库开发,我开始学习Aqueduct(https://aqueduct.io/docs/getting_started/)。我注意到,渡槽3.3.0+1(它是目前稳定的渡槽版本(只适用于dart<2.8.0.

因此,我想知道我是否可以在mac上安装两个版本的dart。如果是,我该怎么做?当我分别或同时使用飞镖和aquedart时(如果可能的话(,如何切换或选择不同版本的飞镖?

编辑:我这样做是因为我在运行aqueduct create project时遇到错误。有什么解决方案吗?

-- Aqueduct CLI Version: 3.3.0+1
*** Uncaught error
Bad state: No element
**** Stacktrace
* #0      ListMixin.firstWhere (dart:collection/list.dart:150:5)
* #1      CLIAqueductGlobal.aqueductPackageRef (package:aqueduct/src/cli/commands/create.dart:342:10)
* #2      CLIAqueductGlobal.templateDirectory (package:aqueduct/src/cli/commands/create.dart:347:12)
* #3      CLIAqueductGlobal.getTemplateLocation (package:aqueduct/src/cli/commands/create.dart:351:12)
* #4      CLITemplateCreator.handle (package:aqueduct/src/cli/commands/create.dart:51:27)
* #5      CLICommand.process (package:aqueduct/src/cli/command.dart:159:20)
* <asynchronous suspension>
* #6      CLICommand.process (package:aqueduct/src/cli/command.dart:135:12)
* #7      main (file:///C:/Users/dos/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/aqueduct-3.3.0+1/bin/aqueduct.dart:9:27)
* #8      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
* #9      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
****

这不是真的。在pubsbpec.yaml 中,渡槽和Flutter手柄Dart版本低于3.0.0

我和我的兄弟正在进行一个开发项目,我正在将其与最新的输水管道一起使用

Flutter (Channel master, 1.24.0-4.0.pre.138, on Mac OS X 10.15.7 19H2
darwin-x64, locale en-BR)

你不需要担心flutter的飞镖sdk,它可以单独处理

对于用户来说,与flutter分离的新版飞镖只是使用Homebrew

brew tap dart-lang/dart
brew install dart

在你的flutter项目中,你用新的dart路径覆盖.vscode文件夹中的settings.json(我使用的是flutter_master构建,所以我也不得不覆盖它,而不是flutter-stable(

{
"dart.flutterSdkPath": "~/Library/flutter_master/bin",
"dart.sdkPath": "/usr/local/bin/dart"
}

更新1:

使用以下更新您的pubspec.yaml

dependencies:
aqueduct: 3.3.0+1
dependency_overrides:
postgres: 2.2.0

你提到的错误也发生在我身上,我忘了提了。我很久以前在这个github线程中发现的问题

我在运行aqueduct create project时遇到的EDIT问题是由于最初没有正确设置pub。

如果你面临这个问题,请使用

  1. 将dart-sdk插入到路径环境变量中。有关详细信息,请关注此链接的前几分钟https://www.youtube.com/watch?v=VdcJ2PAzXWs&ab_channel=尼克曼宁。这允许您使用pub
  2. 如果您正确地遵循了上面的步骤,那么您可以运行pub global activate aqueduct而不是flutter pub global activate aqueduct,然后在没有任何问题的情况下创建项目

最新更新