Below is a description of setting up a Flutter development environment using Visual Studio Code on macOS.
Obviously you'll have to install Visual Studio Code first. :)
Then click the plugins view (on the left sidebar) and install the following plugins:
To get the best syntax highlighting and file browsing, also do the following:
Next, you also need to get the latest Flutter SDK. Just follow the official directions and add make sure to add the path to .bash_profile
or .zprofile
:
export PATH="$PATH:/Users/username/path/to/flutter-x.x.x/bin"
You can follow the directions on Flutter's website to enable iOS and Android emulators. You can install new Android emulators using Android Studios AVD Manager... menu.
Once the emulators are ready to go you have to add a Debug Configuration in VSCode...choose the Debug / Add Configuration... menu. The configuration should be the following:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Flutter",
"request": "launch",
"type": "dart",
"program": "${workspaceRoot}/lib/main.dart"
}
]
}
Before you can install to a real iOS device you need to install some more tools with Homebrew:
brew update
brew install --HEAD usbmuxd
brew link usbmuxd
brew install --HEAD libimobiledevice
brew install ideviceinstaller
First you need to start the simulator(s). You can do this from VSCode by openning the command pallet (View / Command pallett...) and typing "emulator" and select "Flutter: Launch emulator". Just select the appropriate platform and version and wait for the simulator to boot.
Alternatively you can just plug in your device via USB.
Any simulator you have booted (or device you plugged in) will become connected and available to choose in the bottom right-hand corner of your VSCode window. Select the desired one and choose one of the following two options:
Once you are running, the Run/Reload/Hot Reload toolbar should become visible.
By default any time you save a file in VSCode Hot Reload will run. You can also manually trigger it from the toolbar or using the shortcut key (hover over the toolbar to see what it is).
If you want to run the app in multiple simulators at the same time, you'll need to launch from command line (you can then press r to hot reload them):
flutter run -d all
Whenever you run into some issues you can run flutter doctor in your project folder. This will give you a report of any project or system configuration problems that you may have.
flutter doctor
I recommend downloading the new version of flutter into a new folder, then setting your bash path to the new flutter path (see above).
After this you should quit VSCode, and run the following in your project's root folder:
flutter pub get
flutter doctor