DEV Community

Jan Mewes
Jan Mewes

Posted on

Setting up Flutter in Android Studio

This blog post explains how to set up and configure Flutter with Android Studio. It is assumed that Dart is already installed on the system. The shell commands were tested on Ubuntu 20.04, but they should be the same for macOS and probably similar for Windows.

Install Flutter

For the setup of Flutter, the Flutter Version Management tool (FVM) can be used. One of the advantages of that community tool over the approach explained in the official setup instructions is that it makes it convenient to switch back and forth between different Flutter versions, since no rebuilds of the Flutter SDK are required after switching the release channel.

FVM can be installed using the Dart package manager:

dart pub global activate fvm
Enter fullscreen mode Exit fullscreen mode

After the installation of the fvm package, you should include its bin directory into your shell profile (e.g. ~/.bashrc).

export PATH="$PATH:/home/jdoe/fvm/default/bin"
Enter fullscreen mode Exit fullscreen mode

To use a specific Flutter version (i.e. stable, beta, dev, or master), run the fvm global command with the required Flutter channel as a positional parameter:

fvm global beta
flutter --version
Enter fullscreen mode Exit fullscreen mode

Configure Android Studio

When you open a new Flutter project for the first time after installing Android Studio and the Flutter plugin, it will prompt you to enable Dart support. After clicking on the "Enable Dart support" link, Android Studio tries to auto-detect your Dart and Flutter version.

start

You may also click on "Open Dart settings" and configure the path to the Dart and Flutter SDK manually.

Assuming the usage of FVM, the path with needs to be entered for the Dart SDK is e.g. /home/jdoe/fvm/default/bin/cache/dart-sdk.

dart-sdk

The path required for the Flutter SDK is e.g. /home/jdoe/fvm/default.

flutter-sdk

Discussion (0)