Knowing the Flutter project structure helps you find and organize your app files easily.
Flutter project structure
Introduction
Syntax
Flutter
my_flutter_app/ android/ ios/ lib/ test/ pubspec.yaml README.md .gitignore
lib/ is where your Dart code lives, especially main.dart.
pubspec.yaml manages app info, dependencies, and assets.
Examples
lib/ with folders for screens and widgets.Flutter
lib/ main.dart screens/ widgets/
Flutter
pubspec.yaml
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2android/ folder.Flutter
android/
app/
src/
main/
AndroidManifest.xmlios/ folder.Flutter
ios/
Runner.xcodeproj
Runner/
Info.plistSample App
This simple app shows text on the screen. It lives inside the lib/main.dart file in your Flutter project.
Flutter
import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( home: Scaffold( body: Center( child: Text('Hello Flutter Project Structure!'), ), ), ); } }
Important Notes
Always keep your Dart code inside the lib/ folder.
Use pubspec.yaml to add images, fonts, and packages.
Folders android/ and ios/ contain platform-specific code and settings.
Summary
The Flutter project has folders for code (lib/), platform files (android/, ios/), and tests (test/).
pubspec.yaml manages app info, dependencies, and assets.
Understanding this structure helps you build and organize your app smoothly.
Practice
1. Which folder in a Flutter project contains the main Dart code for your app?
easy
Solution
Step 1: Identify the folder purpose
Thelib/folder is where Dart code for the app lives.Step 2: Compare with other folders
android/andios/hold platform-specific files,test/holds tests.Final Answer:
lib/ -> Option AQuick Check:
Main Dart code folder = lib/ [OK]
Hint: Main app code is always in lib/ folder [OK]
Common Mistakes:
- Confusing android/ with code folder
- Thinking test/ holds main code
- Mixing ios/ with Dart code
2. Which file manages app dependencies and assets in a Flutter project?
easy
Solution
Step 1: Understand file roles
pubspec.yamlis the config file for dependencies and assets.Step 2: Differentiate from other files
main.dartis code,build.gradleis Android build config,AndroidManifest.xmlis Android app manifest.Final Answer:
pubspec.yaml -> Option BQuick Check:
Dependencies and assets file = pubspec.yaml [OK]
Hint: pubspec.yaml always manages dependencies and assets [OK]
Common Mistakes:
- Choosing main.dart as config file
- Confusing build.gradle with Flutter config
- Mixing AndroidManifest.xml with Flutter dependencies
3. What will happen if you put your test files inside the
lib/ folder instead of test/?medium
Solution
Step 1: Understand folder roles
lib/is for app code;test/is for tests only.Step 2: Consequence of wrong placement
Putting tests inlib/includes them in app build, increasing size unnecessarily.Final Answer:
Tests may be included in the app build, increasing size -> Option DQuick Check:
Tests in lib/ increase app size [OK]
Hint: Keep tests only in test/ folder to avoid bloated app [OK]
Common Mistakes:
- Assuming tests run normally in lib/
- Thinking app will fail to compile
- Believing tests auto-move folders
4. You accidentally deleted the
android/ folder in your Flutter project. What is the likely result?medium
Solution
Step 1: Role of android/ folder
Theandroid/folder contains platform-specific files needed to build Android apps.Step 2: Effect of deletion
Deleting it causes build errors when targeting Android because required files are missing.Final Answer:
You will get errors when building for Android platform -> Option CQuick Check:
Missing android/ folder causes Android build errors [OK]
Hint: android/ folder is essential for Android builds [OK]
Common Mistakes:
- Assuming app runs without android/ folder
- Thinking iOS build is affected
- Believing Flutter auto-recreates android/
5. You want to add a new image asset to your Flutter app. Which two steps must you do to use it correctly?
hard
Solution
Step 1: Store image in assets/ folder
Images should be placed in a dedicated folder likeassets/for organization.Step 2: Declare asset in pubspec.yaml
You must list the image path underflutter/assetsinpubspec.yamlto use it.Final Answer:
Place the image in assets/ folder and declare it in pubspec.yaml -> Option AQuick Check:
Assets folder + pubspec.yaml declaration = correct asset use [OK]
Hint: Always declare assets in pubspec.yaml after adding files [OK]
Common Mistakes:
- Putting images in lib/ folder
- Not declaring assets in pubspec.yaml
- Placing images in android/ or test/ folders
Recommended
Ready to prove it?
Pass the test and this pattern moves unknown
10 questions ~5 mineasy hard
