How to install two different version of dart for flutter and aqueduct in a macos
Solution 1
The problem I faced with the EDIT where I get an error when I run aqueduct create project
is due to not setting up pub properly in the first place.
If you are facing this problem make use to
- Insert dart-sdk into your path environment variable. for more information follow first few minutes of this link https://www.youtube.com/watch?v=VdcJ2PAzXWs&ab_channel=NickManning. This allows you to use
pub
. - If you have properly followed above step then you can Run
pub global activate aqueduct
NOTflutter pub global activate aqueduct
and later create the project without anyone problem.
Solution 2
This is not true. Aqueduct and Flutter handles Dart version lower than 3.0.0 in pubsbpec.yaml
I am on a dev project with my brother and I am using this with latest working aqueduct
Flutter (Channel master, 1.24.0-4.0.pre.138, on Mac OS X 10.15.7 19H2
darwin-x64, locale en-BR)
You don't need to worry with flutter's dart sdk, it handles it alone
To user a new version of dart separate from flutter is just using Homebrew
brew tap dart-lang/dart
brew install dart
In your flutter project you override in settings.json inside .vscode folder with the new dart path (I am using flutter_master build, so I had to override it too instead of flutter stable)
{
"dart.flutterSdkPath": "~/Library/flutter_master/bin",
"dart.sdkPath": "/usr/local/bin/dart"
}
UPDATE 1:
Update your pubspec.yaml with the following
dependencies:
aqueduct: 3.3.0+1
dependency_overrides:
postgres: 2.2.0
The error you mention happens the same with me, I forgot to mention it. The issue I found a long time ago in this github thread
Malith Kuruppu
Updated on December 25, 2022Comments
-
Malith Kuruppu over 1 year
Currently I have dart installed with flutter, versions as below:
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)
I was mainly working with Mobile App frontend development, therefore this setup was good for me.
But for backend database development I started learning Aqueduct (https://aqueduct.io/docs/getting_started/). I noticed that aqueduct 3.3.0+1 (which is the current stable version of aqueduct) only works with dart <2.8.0.
Therefore, I wondering if I can have two versions of dart installed in my mac. If so how I can do it? And how to switch or select different versions of dart for flutter and aquedart when I am working with them separately or at the same time (if that is possible)?
Edit: I am doing this because I am getting an error when I run
aqueduct create project
. Any solution?-- 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) ****
-
Malith Kuruppu over 3 yearsI am doing this due to the error mentioned in the EDIT of the main post. -- Aqueduct CLI Version: 3.3.0+1 *** Uncaught error Bad state: No element
-
Malith Kuruppu over 3 yearsdid you get any error when you run aqueduct create project? as in the error in the EDIT
-
Kohls over 3 yearsThis is a postgre plugin error compatibility, you have to override a new version in pubspec.yaml
-
Kohls over 3 yearsI updated the answer with new details to fix your problem