How to configure Flutter specific paths for Dart and .pub-cache

106 Views Asked by At

I have both Flutter and Dart installed independently, because I need a specific version of Dart for some tasks.

This causes Flutter to complain about Dart path (on MacOS, but probably same on Linux):

Warning: dart on your path resolves to /opt/homebrew/Cellar/dart/3.2.4/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/francesco/flutter. Consider adding /Users/francesco/flutter/bin to the front of your path.

Is there a way for Flutter to configure path for Dart (and .pub-cache presumably) overriding the global variables?

My .zshrc below:

### DART
export PATH="$HOME/.pub-cache/bin:$PATH"
export PATH="$HOME/flutter/bin:$PATH"
export PATH="/opt/homebrew/opt/dart/bin:$PATH"

See a use case for this question. See also this discussion with Flutter team members.

1

There are 1 best solutions below

3
Aizan Sagheer On

If you want to run different versions of Flutter on your system. You need to use FVM. And you can't override the global path. However you can downgrade or upgrade your SDK by the command

flutter upgrade 

and

flutter downgrade <your version>