From "What is a program?" to your first real app โ step by step
A computer program is just a list of instructions you give to a computer. Just like a recipe tells a chef exactly what to do โ step by step โ a program tells the computer exactly what to do.
Computers speak in 0s and 1s (machine code). That's impossible for humans to write! So we invented programming languages โ human-readable text that gets translated.
| Language | Used For |
|---|---|
| ๐ Python | Data, AI, scripts |
| ๐ JavaScript | Web browsers |
| ๐ฏ Dart | Flutter apps |
| โ Java/Kotlin | Android apps |
| ๐ Swift | iOS apps |
An app (application) is a program that runs on a phone, tablet, or computer. You use apps every day:
All of these were built by humans writing code. You will learn to do this too!
Think of it as the grammar & words of a language.
Think of it as a box of LEGO bricks for building UIs.
A variable is like a labelled box that stores information. You give it a name, and put a value inside.
| Type | What it stores | Example |
|---|---|---|
String | Text | "Hello" |
int | Whole numbers | 42 |
double | Decimal numbers | 3.14 |
bool | Yes / No | true |
int is perfect.int!| Symbol | Meaning | Example | Result |
|---|---|---|---|
+ | Add | 5 + 3 | 8 |
- | Subtract | 10 - 4 | 6 |
* | Multiply | 3 * 4 | 12 |
/ | Divide (decimal) | 7 / 2 | 3.5 |
~/ | Divide (whole) | 7 ~/ 2 | 3 |
% | Remainder | 7 % 2 | 1 |
These compare two values and return true or false
| Symbol | Meaning | Example |
|---|---|---|
== | Equal to | 5 == 5 โ true |
!= | Not equal | 5 != 3 โ true |
> | Greater than | 8 > 3 โ true |
< | Less than | 2 < 9 โ true |
>= | Greater or equal | 5 >= 5 โ true |
<= | Less or equal | 3 <= 4 โ true |
You can combine Strings with + or use string interpolation with $
Your program needs to make decisions based on conditions โ just like you do every day!
When you have many specific values to check, switch is cleaner than many if/else
Imagine printing numbers 1 to 100. Without loops you'd write print(1); print(2); print(3)... 100 times! Loops let you repeat code automatically.
required means you MUST pass that argument. Missing it causes an error!
ClassName() to create an object. The constructor runs automatically.
null means "nothing" or "empty" โ like a box that has no value inside. Dart's null safety system protects you from errors caused by accidentally using an empty box.
Always has a value. Safe to use directly.
Might be empty. Use ?. and ?? for safety.
| Operator | Name | What it does | Example |
|---|---|---|---|
? | Nullable type | Allows null values | String? name |
?. | Null-aware access | Only accesses if not null | name?.length |
?? | Null coalescing | Use right side if left is null | name ?? "Guest" |
! | Null assertion | "I promise it's not null" | name! |
In Flutter, every single piece of your UI โ text, buttons, images, layouts โ is called a Widget. Think of widgets as LEGO bricks you combine to build screens.
A widget that shows words on screen
A box widget with color/size/padding
A tappable button widget
Stacks widgets vertically
Places widgets side by side
Displays a picture
Every Flutter screen is a tree of nested widgets. Parent widgets contain child widgets.
initState() โ runs ONCE when widget first appears. Load your data here.
setState() โ triggers a rebuild. The screen refreshes with new data.
dispose() โ runs ONCE when widget is removed. Clean up timers/listeners here.
When your app needs to fetch data from the internet (like loading posts or weather), it takes time. Your app can't just freeze and wait โ it needs to stay responsive. This is called asynchronous programming.
A Future is like a promise: "I'll give you the data... but not immediately." It runs in the background.
Real apps load data from APIs. Add the http package to pubspec.yaml, then:
FutureBuilder automatically shows different widgets depending on whether data is loading, loaded, or errored.
You don't have to write everything yourself. Other developers share reusable code as packages. You find them at pub.dev.
Thousands of free, ready-to-use packages for anything: maps, charts, authentication, paymentsโฆ
| Package | What it does |
|---|---|
http | Fetch data from internet |
provider | Simple state management |
shared_preferences | Save settings locally |
google_fonts | Use Google Fonts |
cached_network_image | Load & cache images |
url_launcher | Open links in browser |
image_picker | Pick photos from gallery |
intl | Format dates & numbers |
flutter pub get in your terminal to download the packages.Download Flutter SDK from flutter.dev/get-started. Install VS Code with the "Flutter" extension. This gives you color coding, autocomplete, and a run button.
Fix any โ red items. Every item should be โ green before continuing.
Open an Android emulator or connect your phone first. Then press r for Hot Reload, R for Hot Restart, q to quit.
| Concept | Syntax | Example |
|---|---|---|
| Declare variable | Type name = value; | int x = 5; |
| Auto type | var name = value; | var name = "Alice"; |
| Constant | final / const | final pi = 3.14; |
| If condition | if (cond) {} else {} | if (x > 5) {...} |
| For loop | for (init; cond; step) | for (int i=0; i<5; i++) |
| For-each | for (var x in list) | for (var f in fruits) |
| Function | Type name(params) {} | int add(int a, int b) {} |
| Class | class Name { ... } | class Dog { ... } |
| Create object | ClassName(args) | Dog("Max", 3) |
| Async function | Future<T> fn() async {} | Future<String> fetch() async |
| Await result | await asyncFunction() | var data = await fetch(); |
| Nullable type | Type? | String? name |
| Null fallback | value ?? default | name ?? "Guest" |
| String template | "text $variable" | "Hello $name" |
| Print output | print(value) | print("hello") |
| Error | Cause | Fix |
|---|---|---|
Null check operator on null value | Used ! but value was null | Check if value is null first, or use ?. |
No Material widget found | Forgot to wrap with MaterialApp | Wrap your widget tree in MaterialApp |
setState called after dispose | Calling setState on removed widget | Check if (mounted) setState((){}) |
RangeError: Index out of range | List index doesn't exist | Check list.length before accessing |
Could not find package | Package not in pubspec.yaml | Add to pubspec.yaml, run flutter pub get |
Missing concrete implementation | Forgot to override required method | Add the missing @override method |