Sub topic 4
Setting Up Your Flutter Editor
Assume that you already know basic variables, functions, and classes, and that the Flutter SDK is installed. You should also be comfortable opening a terminal and navigating folders. This chapter uses Visual Studio Code, but the same ideas apply to Android Studio or IntelliJ IDEA.
Choose an editor
A Flutter editor should provide four things:
- Dart and Flutter syntax highlighting.
- Static analysis, which reports likely errors before you run the app.
- Code completion and navigation.
- Commands for launching, debugging, and reloading the app.
Visual Studio Code is lightweight and works well with the Flutter command-line tools. Android Studio and IntelliJ IDEA provide similar features, plus deeper Android tooling.
| Editor | Best fit | Flutter support |
|---|---|---|
| Visual Studio Code | Fast editing and a small interface | Flutter extension, which also installs Dart support |
| Android Studio | Android development and emulator management | Flutter and Dart plugins |
| IntelliJ IDEA | JetBrains workflows | Flutter and Dart plugins |
Install the Flutter and Dart support
In Visual Studio Code, open the Extensions view and install the Flutter extension published by Dart Code. The extension adds Dart support automatically.
After installation, reload the editor. Open the generated Flutter project by selecting its folder, not an individual file. The editor should recognize the folder because it contains pubspec.yaml.
The extension adds several useful controls:
- A device selector in the status bar.
- Run and debug buttons.
- Breakpoints in the editor gutter.
- Widget refactoring commands.
- Hot reload while a debug session is active.
- Problems from
flutter analyze.
If the editor does not show Flutter controls, open the integrated terminal and check that the flutter command is available:
flutter --version
flutter doctor
flutter devicesThese commands must run in the same environment that the editor uses. A terminal outside the editor may have a different PATH, which is the list of folders where executable commands are searched.
Configure formatting and analysis
Dart has an opinionated formatter. Run it instead of manually aligning code:
dart format .
flutter analyzeThe first command formats Dart files in the current project. The second checks the project for analyzer warnings and errors.
You can format a file when saving. In Visual Studio Code, open Settings, search for Format On Save, and enable it. Then set Dart as the default formatter if the editor asks you to choose one.
Keep analyzer warnings visible. They often identify unused imports, incorrect types, and APIs that are no longer recommended. Fixing these warnings early makes later debugging easier.
Understand the editor workflow
The editor, Flutter extension, project files, and run target form one workflow:
Open lib/main.dart, select a run target, and start debugging. While the app is running, edit a widget and save the file. The extension sends a hot reload request, allowing many UI changes to appear without restarting the application.
Use the terminal for project-wide commands and the editor for navigation, editing, breakpoints, and debugging. This separation makes it easier to reproduce a command outside the editor when diagnosing a problem.
Exercise
The Flutter extension is installed, but no run button or device appears. What should you check first?
Show answer
Confirm that the editor opened the project folder, then run flutter doctor and flutter devices in the editor's integrated terminal. Check the reported errors and whether a run target is available.