-1

I'm having a bit of confusion about Dart and Pub installs on my system. I Use Android Studio and Flutter which comes with Dart, and if run Dart --version command in terminal I get Dart SDK version: 2.10.4 (stable) (Wed Nov 11 13:35:58 2020 +0100) on "macos_x64" which is the latest Flutter stable channel I installed.

Then to install Aqueduct with pub global activate aqueduct I was having the error pub command not found so I installed it and I had to also install PostgreSQL and Dart via home-brew . Now to try and solve a bug that seems to be related to the latest version of dart Aqueduct db generate error: Bad state: NoSuchMethodError: The getter 'length' was called on null I run brew install dart@2.8 but then if I run Dart --version again I still get Dart SDK version: 2.10.4 (stable) (Wed Nov 11 13:35:58 2020 +0100) on "macos_x64" Here is the print from console:

Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 7 formulae.

==> Installing dart@2.8 from dart-lang/dart
==> Downloading https://storage.googleapis.com/dart-archive/channels/stable/rele
Already downloaded: /Users/vinnytwice/Library/Caches/Homebrew/downloads/f3ce4b575125184d766bb56931b479589b16972fb0bcfd1e00c841a316c85e25--dartsdk-macos-x64-release.zip
Warning: Your Xcode (11.5) is outdated.
Please update to Xcode 12.3 (or delete it).
Xcode can be updated from the App Store.

Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Preferences or run:
  softwareupdate --all --install --force

If that doesn't show you an update run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/more/.

==> Caveats
Please note the path to the Dart SDK:
  /usr/local/opt/dart@2.8/libexec

dart@2.8 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have dart@2.8 first in your PATH run:
  echo 'export PATH="/usr/local/opt/dart@2.8/bin:$PATH"' >> ~/.zshrc

==> Summary
  /usr/local/Cellar/dart@2.8/2.8.1: 502 files, 486MB, built in 34 seconds

How can I check what versions I have installed on the system and Flutter? Many thanks

Update

After running brew uninstall dart when I open the aqueduct project then I get Dart SDK is not configured message from Android Studio. If I then point to the Flutter's dart-sdk folder Android Studio accept it but I need a 2.7 version to work well with Aqueduct's Postgres db.

So I guess the system should be set with both Flutter with its own Dart version for Flutter projects and a global Dart version for non Flutter projects like this Aqueduct project. But then how do I set my path? Should I include both in my .zshrc file?

Vincenzo
  • 5,304
  • 5
  • 38
  • 96
  • Maybe this section will help you: https://flutter.dev/docs/get-started/install/macos#update-your-path (see the note above platform setup) – osaxma Jan 03 '21 at 19:39
  • 1
    See this answer and do likewise for dart: https://stackoverflow.com/questions/55783494/how-to-use-two-version-of-flutter-on-same-device-for-different-projects – psimons Aug 01 '23 at 13:29
  • @psimons thank you for pointing that out. – Vincenzo Aug 01 '23 at 21:31

2 Answers2

1

Not to answer your whole question... addressing this part:

I was having the error pub command not found so I installed it

pub is going away. Learn to start typing "dart pub" or "flutter pub", depending on which subset of commands you want.

Randal Schwartz
  • 39,428
  • 4
  • 43
  • 70
  • Hi Randal, Indeed when I still was trying Dart 2.8 in Android Studio Terminal window had to use `dart pub run aqueduct db upgrade` but `aqueduct db generate` worked just fine. Now on dart 2.7 I just use `aqueduct db generate` and `aqueduct db upgrade` commands. No `dart pub` or `flutter pub` needed.. do you know why is it so? – Vincenzo Jan 06 '21 at 11:08
0

Finally figured it out.. To have a different Dart version for non Flutter projects use Home-brew as install instructions say with brew install dart command and it will install the latest version.. If you need a specific version as I did install with brew install dart@2.7, and then to use it install docs says to use the brew switch dart command but I got the switch command is disabled in terminal message in terminal so I used the link command instead as suggested as brew link --overwrite dart@2.7 To set it in Android Studio the correct path is /usr/local/Cellar/dart@2.7/2.7.0/libexec as when installing it the dart@2.7 is keg-only, which means it was not symlinked into /usr/local, because this is an alternate version of another formula. message suggested it doesn't get installed in normal route /usr/local/Cellar/dart there you'll find the latest SDK installed with the first brew install dart command..

Update the path for it in .zshrc file and it's all done..

Hope this will help others as getting it set up correctly got me scratching my head a bit .. Cheers.

Vincenzo
  • 5,304
  • 5
  • 38
  • 96