Search code examples
flutterdartaqueduct

How to install two different version of dart for flutter and aqueduct in a macos


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)
  ****

Solution

  • 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

    1. 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.
    2. If you have properly followed above step then you can Run pub global activate aqueduct NOT flutter pub global activate aqueduct and later create the project without anyone problem.