Flutter and Dart Extensions and Development Setup – Detailed Notes
Flutter development in Visual Studio Code (VS Code) becomes much easier when the Flutter and Dart extensions are correctly installed and configured. These extensions provide syntax highlighting, code completion, error detection, debugging, widget assistance, project management, hot reload, device selection, and access to Flutter DevTools.
For professional Flutter learning and training, visit JustAcademy Flutter Training. You can also register for a demo through JustAcademy Course Demo Registration.
1. What Are Flutter and Dart Extensions?
VS Code uses extensions to add programming-language and framework-specific functionality. For Flutter development, the two important extensions are the Flutter extension and the Dart extension.
The official Flutter documentation states that installing the Flutter extension also installs the Dart extension. Together, they provide the core editor support required for Dart and Flutter development in VS Code.
Flutter Extension
The Flutter extension adds Flutter-specific functionality to VS Code.
Dart Extension
The Dart extension provides support for the Dart programming language, which is used to build Flutter applications.
2. Why Are These Extensions Required?
VS Code by itself is a general-purpose code editor. Flutter and Dart extensions transform it into a development environment suitable for Flutter applications.
| Feature |
Purpose |
| Syntax Highlighting |
Makes Dart and Flutter code easier to read. |
| Code Completion |
Suggests classes, methods, widgets, properties, and parameters. |
| Error Detection |
Highlights coding and analysis problems. |
| Code Navigation |
Helps navigate to definitions and usages. |
| Debugging |
Provides breakpoints, variables, call stack, and debugging controls. |
| Hot Reload |
Allows quick updates to a running Flutter application. |
| Hot Restart |
Restarts the Flutter application while debugging. |
| Device Selection |
Allows developers to choose a target device. |
| DevTools |
Provides debugging, inspection, and performance tools. |
3. Prerequisites for Flutter and Dart Development
Before installing the extensions, make sure the basic Flutter development environment is available.
- Visual Studio Code
- Flutter SDK
- Dart SDK
- Git
- A supported target platform
- Flutter extension
- Dart extension
The Dart SDK is normally included with the Flutter SDK, so developers generally do not need to install a separate Dart SDK when setting up Flutter.
4. Install Visual Studio Code
VS Code is the editor used to write and manage Flutter and Dart source code.
Installation Steps
- Download and install Visual Studio Code.
- Launch VS Code.
- Open the Extensions panel.
- Search for Flutter.
- Install the official Flutter extension.
The Flutter extension installation also provides Dart support through the Dart extension.
5. Installing the Flutter Extension
The Flutter extension is the primary extension required for Flutter development in VS Code.
Step-by-Step Installation
- Open Visual Studio Code.
- Click the Extensions icon in the Activity Bar.
- Search for Flutter.
- Find the official Flutter extension.
- Click Install.
- Wait for the extension installation to complete.
- Reload or restart VS Code if requested.
Using the Command Palette
You can also open the Command Palette:
Ctrl + Shift + P
On macOS:
Cmd + Shift + P
Then search for extension-related commands and install the Flutter extension.
6. Installing the Dart Extension
The Dart extension provides language support for Dart. When the official Flutter extension is installed, the Dart extension is installed as well.
Dart Extension Features
- Dart syntax highlighting
- Code completion
- Type analysis
- Code navigation
- Refactoring support
- Error and warning detection
- Debugging support
- Dart formatting
- DevTools integration
Checking the Dart Extension
- Open the Extensions panel.
- Search for Dart.
- Verify that the Dart extension is installed and enabled.
7. Flutter SDK and Dart SDK Relationship
Flutter uses Dart as its programming language. The Flutter SDK includes the Dart SDK needed by the Flutter development environment.
Flutter SDK
│
├── Flutter Framework
├── Flutter CLI
├── Dart SDK
└── Flutter Tools
Flutter SDK
The Flutter SDK provides the framework, command-line tools, libraries, and other components required to develop Flutter applications.
Dart SDK
The Dart SDK provides the Dart language tools and runtime components required to write and analyze Dart code.
8. Configure the Flutter SDK in VS Code
VS Code needs to know where the Flutter SDK is located.
Using Flutter: New Project
- Open VS Code.
- Open the Command Palette.
- Search for Flutter: New Project.
- Select the command.
- If VS Code asks for the Flutter SDK location, select the appropriate SDK directory.
If Flutter is not installed, current Flutter tooling can also guide you through downloading the SDK from VS Code.
Example Flutter SDK Location
C:\src\flutter
A different location can be used depending on your operating system and development setup.
9. Add Flutter to PATH
The Flutter SDK's bin directory should be available through the system PATH when using Flutter from the command line.
Windows Example
C:\src\flutter\bin
macOS/Linux Example
/path/to/flutter/bin
After changing PATH, close and reopen terminal windows and restart VS Code so the updated environment is recognized.
10. Verify Flutter and Dart Installation
Open the VS Code integrated terminal and run:
flutter --version
Then check the complete development environment:
flutter doctor
For detailed diagnostic information:
flutter doctor -v
Check Dart Version
dart --version
These commands help verify that Flutter and Dart are accessible from the terminal.
11. Run Flutter Doctor from VS Code
VS Code provides a Flutter Doctor command through the Flutter extension.
- Open VS Code.
- Press Ctrl + Shift + P.
- Search for Flutter: Run Flutter Doctor.
- Select the command.
- Review the Flutter Doctor output in the Output panel.
Flutter Doctor checks important components of the Flutter development environment and reports detected problems.
12. Create a New Flutter Project
Once the extensions and Flutter SDK are configured, you can create a Flutter project directly from VS Code.
Steps
- Open VS Code.
- Press Ctrl + Shift + P.
- Type Flutter: New Project.
- Select Application.
- Select the parent directory.
- Enter the project name.
- Wait for Flutter to generate the project.
Example Project Name
student_flutter_app
Flutter project names generally use the lowercase_with_underscores convention.
13. Flutter Project Structure
student_flutter_app/
│
├── android/
├── ios/
├── lib/
│ └── main.dart
├── test/
├── web/
├── windows/
├── macos/
├── linux/
├── pubspec.yaml
├── pubspec.lock
└── README.md
Important Components
| Component |
Purpose |
| lib/ |
Contains the main Dart and Flutter application code. |
| main.dart |
Common entry point of the Flutter application. |
| pubspec.yaml |
Defines project metadata, dependencies, assets, and Flutter configuration. |
| test/ |
Contains automated tests. |
| android/ |
Contains Android-specific project files. |
| ios/ |
Contains iOS-specific project files. |
| web/ |
Contains web-specific project files. |
14. Understanding main.dart
The main.dart file normally contains the entry point of a Flutter application.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Flutter App'),
),
body: const Center(
child: Text('Hello Flutter'),
),
),
);
}
}
Important Dart Concepts
import loads a library.
main() is the entry point of the Dart application.
runApp() starts the Flutter widget tree.
class defines a Dart class.
extends is used for inheritance.
build() describes the widget's UI.
15. Dart Code Completion
The Dart extension provides intelligent code completion based on Dart's type information.
Example
String studentName = 'Rahul';
studentName.
After typing the dot, VS Code can display available properties and methods for the String type.
16. Flutter Widget Suggestions
The Flutter extension provides suggestions for widgets and widget properties.
Example
Scaffold(
appBar: AppBar(
title: const Text('Home'),
),
body: const Center(
child: Text('Welcome'),
),
)
When editing Flutter widgets, VS Code can suggest constructors, properties, and parameters.
17. Code Navigation
The Dart extension makes it easier to navigate through a Flutter project.
Go to Definition
You can use:
F12
This can open the definition of a class, method, property, or other supported symbol.
Find References
You can use:
Shift + F12
This helps find locations where a particular class, method, variable, or other symbol is referenced.
18. Error Detection and Problems Panel
The Dart and Flutter extensions analyze source code and can display errors, warnings, and other issues.
Problems Panel
Open the Problems panel using:
Ctrl + Shift + M
The Problems panel can help identify issues such as:
- Syntax errors
- Undefined identifiers
- Incorrect types
- Missing imports
- Unused variables
- Other analyzer warnings
19. Quick Fixes and Code Assists
Code assists and quick fixes help developers modify code efficiently.
Place the cursor on the relevant code and press:
Ctrl + .
Examples of Code Assists
- Wrap a widget with another widget.
- Add a missing import.
- Apply suggested code corrections.
- Perform certain refactoring operations.
- Modify widget structure.
Example
Text('Hello')
A Flutter widget assist can help wrap this widget with another widget, such as Center or Padding.
20. Dart Formatting
Consistent formatting makes Dart code easier to read and maintain.
Format Document
Use the VS Code formatting command or configure format-on-save.
Shift + Alt + F
A typical Dart formatting result might look like:
Column(
children: [
const Text('Name'),
const Text('Flutter Developer'),
ElevatedButton(
onPressed: () {},
child: const Text('Submit'),
),
],
)
21. Enable Format on Save
VS Code can automatically format files when they are saved.
Steps
- Open VS Code Settings.
- Search for Format On Save.
- Enable Editor: Format On Save.
This can help maintain consistent formatting throughout a Dart and Flutter project.
22. Running a Flutter Application
After creating a project, select a target device and start the application.
Using Debug Mode
F5
Using Terminal
flutter run
Run Without Debugging
In VS Code, use:
Run > Start Without Debugging
23. Selecting a Flutter Device
When a Flutter project is open, the VS Code status bar displays Flutter-related information and the currently selected device.
Possible Devices
- Chrome
- Edge
- Android Emulator
- Physical Android Device
- iOS Simulator on macOS
- Windows
- macOS
- Linux
If VS Code displays No Devices, Flutter has not detected a connected or running target device.
24. Hot Reload
Hot reload is an important Flutter development feature. It allows many code and UI changes to be applied to a running application without restarting the complete application.
Example
Initial code:
Text('Welcome')
Change it to:
Text('Welcome to Flutter')
Save the file or use the Flutter hot reload control. The updated UI can appear in the running application while preserving appropriate application state.
25. Hot Restart
Hot restart restarts the Flutter application and resets its current application state.
Command Palette
Flutter: Hot Restart
Hot restart is useful when a change requires the application to restart rather than simply applying a hot reload.
26. Debugging Flutter Applications
VS Code provides integrated debugging support for Flutter applications.
Start Debugging
F5
Debugging Features
- Breakpoints
- Variable inspection
- Debug Console
- Call Stack
- Step Over
- Step Into
- Step Out
- Continue execution
27. Setting Breakpoints
A breakpoint pauses application execution at a particular line of code during debugging.
Example
void calculatePrice() {
int price = 500;
int quantity = 2;
int total = price * quantity;
print(total);
}
Place a breakpoint on the line containing the calculation. When the application reaches that line during debugging, VS Code can pause execution and allow you to inspect variables.
28. Flutter DevTools
Flutter DevTools provides tools for inspecting and debugging Flutter applications. It can be launched from VS Code while a debugging session is active.
DevTools Features
- Flutter Inspector
- Widget tree inspection
- Layout inspection
- Performance analysis
- Memory analysis
- Network inspection
- Logging and debugging tools
Basic DevTools Workflow
- Open the Flutter project root in VS Code.
- Start a debugging session using F5.
- Open the Command Palette.
- Search for DevTools commands.
- Select the required DevTools tool.
29. Flutter Inspector
Flutter Inspector allows developers to inspect the widget tree and investigate the structure and layout of a Flutter application.
Example Widget Tree
MaterialApp
|
└── Scaffold
|
├── AppBar
|
└── Center
|
└── Text
The Inspector helps developers understand how widgets are arranged and how their properties affect the UI.
30. Integrated Terminal
VS Code's integrated terminal allows developers to run Flutter and Dart commands without opening a separate terminal application.
Useful Commands
flutter doctor
flutter doctor -v
flutter --version
dart --version
flutter devices
flutter emulators
flutter pub get
flutter analyze
flutter test
flutter clean
flutter run
31. Working with Packages
Flutter applications can use packages to add functionality such as networking, state management, database access, UI components, and other features.
Add a Package
A package can be added to pubspec.yaml.
dependencies:
flutter:
sdk: flutter
http: ^1.0.0
Then retrieve the dependencies:
flutter pub get
Import the Package
import 'package:http/http.dart' as http;
The exact package version should be selected according to the project's Dart and Flutter compatibility requirements.
32. Understanding pubspec.yaml
The pubspec.yaml file is used to configure important parts of a Flutter project.
name: student_flutter_app
description: A Flutter learning project.
dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
Common Uses
- Project name
- Project description
- Dependencies
- Development dependencies
- Assets
- Fonts
- Flutter configuration
33. Configure Flutter Settings in VS Code
Flutter and Dart provide settings that can be customized through VS Code.
Open Settings
Ctrl + ,
You can search for settings related to:
- Dart
- Flutter
- Formatting
- DevTools
- Debugging
- Closing labels
- Analysis
34. Dart Closing Labels
The Dart extension can display labels after closing delimiters in multiline Dart code. These labels can help identify which widget or expression is being closed.
Example
Column(
children: [
Container(
child: Text('Hello'),
), // Container
],
) // Column
These editor annotations help when working with deeply nested Flutter widget trees.
35. Recommended VS Code Development Workflow
- Install VS Code.
- Install the Flutter extension.
- Verify that the Dart extension is installed.
- Install or configure the Flutter SDK.
- Add Flutter to PATH when required.
- Run
flutter doctor.
- Create or open a Flutter project.
- Run
flutter pub get.
- Select a target device.
- Run the application.
- Use hot reload while developing the UI.
- Use breakpoints for debugging.
- Use Flutter Inspector and DevTools when required.
- Run
flutter analyze.
- Run tests using
flutter test.
- Commit changes using Git.
36. Common Problems and Solutions
Problem 1: Flutter Extension Is Not Visible
Solution:
- Open the Extensions panel.
- Search for Flutter.
- Install the official Flutter extension.
- Reload VS Code.
Problem 2: Dart Extension Is Missing
Solution:
- Open Extensions.
- Search for Dart.
- Install or enable the Dart extension.
- Restart VS Code if necessary.
Problem 3: Flutter Command Is Not Recognized
flutter is not recognized as an internal or external command
Possible solutions:
- Check whether Flutter SDK is installed.
- Verify the Flutter SDK location.
- Check the PATH configuration.
- Close and reopen the terminal.
- Restart VS Code.
- Run
flutter doctor.
Problem 4: No Devices Available
If VS Code shows No Devices, Flutter has not detected a usable target device.
Possible solutions:
- Start an Android emulator.
- Connect a physical Android device.
- Enable USB debugging on an Android device.
- Use Chrome for web development.
- Run
flutter devices.
Problem 5: Project Is Not Detected as Flutter
Make sure you open the project folder that contains the pubspec.yaml file.
my_flutter_app/
├── lib/
├── test/
├── pubspec.yaml
└── README.md
Open my_flutter_app as the workspace folder rather than opening only the lib directory.
37. Practical Example – Flutter Development Setup
Step 1: Check Flutter
flutter doctor
Step 2: Create Project
flutter create learning_app
Step 3: Open Project
cd learning_app
code .
Step 4: Open main.dart
lib/main.dart
Step 5: Add Simple UI
import 'package:flutter/material.dart';
void main() {
runApp(const LearningApp());
}
class LearningApp extends StatelessWidget {
const LearningApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: const Text('Flutter Learning'),
),
body: const Center(
child: Text(
'Flutter and Dart Setup Complete!',
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
),
),
),
),
);
}
}
Step 6: Run the Application
flutter run
Step 7: Test Hot Reload
Change the displayed text and save the file. Use hot reload to see the updated UI.
38. Practical Exercise
Create a Flutter project named student_dashboard using VS Code.
Requirements
- Install and enable Flutter and Dart extensions.
- Run Flutter Doctor.
- Create the Flutter project.
- Create an AppBar titled Student Dashboard.
- Display a student name.
- Display the course name.
- Add a button.
- Run the application on a target device.
- Test hot reload.
- Set a breakpoint.
- Inspect the widget tree using Flutter Inspector.
39. Interview Questions
Q1. What is the Flutter extension?
The Flutter extension adds Flutter-specific development functionality to VS Code, including project creation, debugging, device selection, hot reload, and Flutter tooling integration.
Q2. What is the Dart extension?
The Dart extension provides Dart language support, including syntax analysis, code completion, navigation, formatting, debugging, and DevTools integration.
Q3. Does installing the Flutter extension install Dart support?
Yes. The official Flutter VS Code documentation states that installing the Flutter extension also installs the Dart extension.
Q4. How do you check whether Flutter is configured correctly?
flutter doctor
Q5. What is the purpose of Flutter Doctor?
Flutter Doctor checks the Flutter development environment and reports configuration or dependency issues.
Q6. What is hot reload?
Hot reload applies many source-code and UI changes to a running Flutter application without completely restarting the application.
Q7. What is Flutter Inspector?
Flutter Inspector is a debugging tool that helps developers inspect the widget tree, widget properties, and layout of a Flutter application.
Q8. What is pubspec.yaml?
It is a project configuration file that contains information such as project metadata, dependencies, assets, and Flutter-specific configuration.
40. Development Setup Checklist
- VS Code installed
- Flutter SDK installed
- Dart SDK available through Flutter
- Flutter extension installed
- Dart extension installed
- Flutter SDK configured in VS Code
- Flutter added to PATH where required
flutter doctor checked
- Flutter project created
pubspec.yaml detected
- Target device configured
- Application successfully launched
- Hot reload tested
- Debugging tested
- Flutter Inspector tested
- DevTools tested
41. Key Points to Remember
- Flutter applications are written primarily using the Dart programming language.
- VS Code provides a lightweight environment for Flutter development.
- The Flutter extension adds Flutter-specific development features.
- The Dart extension provides Dart language support.
- Installing the Flutter extension also installs the Dart extension.
- The Flutter SDK contains the Dart SDK used by Flutter development.
flutter doctor is useful for checking the development environment.
flutter pub get retrieves project dependencies.
flutter analyze checks the project for analyzer issues.
- Hot reload speeds up the development cycle.
- Hot restart resets the running application's state.
- Flutter Inspector helps inspect the widget tree and layout.
- DevTools provides advanced debugging and performance tools.
- The project root should contain
pubspec.yaml.
42. Learning Resources
JustAcademy Flutter Training: https://www.justacademy.co/course-detail/flutter-training
JustAcademy Course Demo Registration: https://www.justacademy.co/register-for-course-demo
Flutter and VS Code: Official Flutter VS Code Documentation
Install Flutter Using VS Code: Official Flutter Installation Guide
Flutter DevTools with VS Code: Official Flutter DevTools Documentation
Conclusion
Setting up Flutter and Dart extensions in VS Code is an essential step in creating a productive Flutter development environment. The Flutter extension provides framework-specific tools, while the Dart extension provides language support. After installing the extensions, configuring the Flutter SDK, running Flutter Doctor, creating a project, selecting a device, and testing debugging and hot reload, developers can use VS Code as a complete environment for building and maintaining Flutter applications.