when you run flutter create project_name
, Flutter creates a big folder structure that can feel overwhelming at first. Don’t worry , we’ll go from basics and I’ll explain which files are important, and we’ll build step by step in VS Code.
Step 1: Understanding Flutter Project Structure
When you create a project (flutter create hello_world
), you’ll see folders like:
hello_world/
├── android/ # Native Android code (Java/Kotlin)
├── ios/ # Native iOS code (Swift/Obj-C)
├── web/ # For web apps
├── lib/ # Your main Flutter code (MOST IMPORTANT )
├── test/ # For writing tests
├── pubspec.yaml # Project settings + dependencies
└── README.md
As a beginner, you mostly work in lib/ and pubspec.yaml.
The rest is handled automatically by Flutter.
Step 2: The Important File – lib/main.dart
This is where your app starts.
Inside you’ll see something like:
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
main()
→ starting point of every Dart program.runApp()
→ tells Flutter to draw your app on the screen.MyApp
→ root widget of your app.
Step 3: Simplest Hello World App
Let’s make the minimum code (ignore all other files for now):
import 'package:flutter/material.dart';
void main() {
runApp(
const Center(
child: Text(
'Hello World ',
textDirection: TextDirection.ltr,
),
),
);
}
This is the most basic Flutter app:
Center
→ places text in the center.Text
→ displays “Hello World “.textDirection
→ required in raw Flutter apps.
If you run this, you’ll see only Hello World on screen.
Step 4: Using MaterialApp
(For Modern Apps)
Usually, we wrap the app inside MaterialApp
for Android-like look:
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(
appBar: AppBar(title: Text("My First App")),
body: Center(
child: Text(
"Hello Flutter ",
style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold),
),
),
),
);
}
}
Step 5: What You Should Focus On First
- lib/main.dart → write your UI here.
- Widgets (Text, Container, Row, Column, Image, Button).
- pubspec.yaml → to add dependencies (like http, firebase, etc).