Question #182EasyGeneral

What is the root dir of your project ?

Answer

Overview

The root directory of a Flutter project is the top-level folder created when you run

text
flutter create
. It contains all configuration files, platform folders, and the
text
lib/
directory with your Dart code.


Flutter Project Root Directory Structure

text
my_flutter_app/              ← Root directory
├── android/                 ← Android native project
│   ├── app/
│   │   └── build.gradle
│   └── build.gradle
├── ios/                     ← iOS native project
│   ├── Runner/
│   └── Podfile
├── lib/                     ← Your Dart/Flutter code
│   └── main.dart            ← App entry point
├── test/                    ← Unit & widget tests
├── assets/                  ← Images, fonts, files
├── web/                     ← Flutter Web support
├── linux/                   ← Flutter Linux support
├── macos/                   ← Flutter macOS support
├── windows/                 ← Flutter Windows support
├── pubspec.yaml             ← Project config & dependencies
├── pubspec.lock             ← Locked dependency versions
├── analysis_options.yaml    ← Dart linting rules
├── README.md
└── .gitignore

Key Files in Root

File/FolderPurpose
text
pubspec.yaml
App name, version, dependencies, assets
text
lib/
All Dart source code
text
lib/main.dart
Entry point (
text
main()
+
text
runApp()
)
text
android/
Android native configuration
text
ios/
iOS native configuration
text
test/
Test files (mirrors lib/ structure)
text
assets/
Static resources (declared in pubspec.yaml)
text
.dart_tool/
Generated Flutter/Dart tool config
text
build/
Generated build outputs (gitignored)

pubspec.yaml — Heart of the Root

yaml
name: my_flutter_app          # Package name
description: My Flutter app
version: 1.0.0+1              # version+buildNumber

environment:
  sdk: '>=3.0.0 <4.0.0'

dependencies:
  flutter:
    sdk: flutter
  http: ^1.2.0
  dio: ^5.4.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  mockito: ^5.4.4

flutter:
  assets:
    - assets/images/          # Declared here, stored in root/assets/
    - assets/icons/
  fonts:
    - family: Roboto
      fonts:
        - asset: assets/fonts/Roboto-Regular.ttf

Checking Your Root Directory

bash
# In terminal, run from root
flutter pub get       # Install dependencies
flutter run           # Run the app
flutter test          # Run tests
flutter build apk     # Build release APK

# The root is wherever pubspec.yaml lives
ls pubspec.yaml       # Confirms you're in root

Root dir = the folder containing

text
pubspec.yaml
. Everything — builds, dependencies, platform configs — is relative to this directory.