Fetch live data. Handle errors. Listen to changes. Real apps only do this.
Press J anytime to jump to any section. Arrow keys to navigate.
You split files, used packages, formatted money. Nice.
import, relative paths
Random, sqrt, pi
now, difference, format
encode/decode data
shared packages
format money/dates
📌 Today: talk to real servers. Last Dart day before Flutter!
Like a chef who makes ONE momo, waits 10 min, then starts next. Kitchen frozen. Customers leave.
📌 Slow task = internet, files, database. We need: don't freeze while waiting.
📌 Sync = one at a time. Async = start slow task, continue others.
Everything today uses these three.
Promise of one value later.
Write async like sync.
Many values over time.
📌 Start with Future. Build up to Streams.
Like a delivery tracking number. You don't have the package yet, but you have a promise it's coming.
📌 Future<T> wraps a value that isn't ready yet.
int will come later.
enables await inside.
simulate a wait.
Dart wraps it in Future.
Aayush writes the menu string. Sita reads it. Works like magic.
await says: pause here, wait for this, then continue. Like waiting for your order at a restaurant.
📌 async marks function. await waits for Future to complete.
Use await only inside async functions.
async function ALWAYS returns a Future.
main() can be async too.
Future<int> mean?await can be used where?await is only allowed inside a function marked async.await fetchMenu() do?await pauses the async function until the Future completes.Like driving without a seatbelt. One crash = done. We need safety.
📌 Real world breaks. Always plan for failure.
Risky code goes here.
If it breaks, handle it.
Keeps running after catch.
Creates a custom error.
Runs no matter what.
Close files, stop loaders, cleanup.
📌 50/50 chance of crash. App never dies. Friendly message instead.
try/catch is used for?finally runs when?throw 'bad' does what?You = customer. API = waiter. Server = kitchen. You tell waiter what you want. Waiter brings food back.
📌 API = way for apps to talk to servers. Always JSON these days.
No login. No rate limit.
Fake data. Real HTTP.
📌 We'll use this to test our restaurant API calls.
Adds to pubspec.yaml automatically.
as http = namespace, short alias so calls read nicely.
📌 Two steps only: pub add + import.
Turn string into a URI.
Returns Future<Response>.
The response text (JSON).
📌 Server sends text. jsonDecode turns it into a Map you can use.
📌 POST = send data to server. Use jsonEncode on the body.
OK, success.
Created new resource.
Not found.
Server broke.
📌 Memory trick: 2xx good, 4xx your fault, 5xx server fault.
Future = bottle of water (one-time).Stream = water tap (keeps flowing).
📌 Stream pushes values as they happen. Perfect for live data.
Start receiving values.
Runs EACH time a value arrives.
Stream keeps pushing on its own.
Makes a Stream.
Push one value.
Yield many times instead.
📌 async + * + yield = Stream. Each yield = new value.
Fire and forget. Keep running.
Pause, consume values, then continue.
📌 Use await for when you want the stream done before moving on.
Keep only matching values.
Transform each value.
First 3 only, then stop.
ONE listener only. Default type. Like a personal phone call.
MANY listeners. Like a radio broadcast.
📌 UI updates = broadcast. One-time job = single.
Sita sees each update without refreshing. Perfect delivery UX.
📌 Need one thing? Future. Need updates? Stream.
yield does what?Fetch menu, handle errors, post orders, stream status. Click each feature.
One-time slow task?
Might fail?
Call a server?
Live updates?
Many listeners?
Send data?
value coming later
pause and wait
catch errors safely
always runs
custom errors
fetch data
send data
many values over time
create streams
openweathermap.org for a free API key
http package
try/catch
flutter-tr06 via PR
📌 Real keys, real weather, real async. This is the capstone of Dart week.
Seven days ago you didn't know Dart. Look at you now.
You know Dart. Now let's build REAL apps.
Dart was the language. Flutter is what you build with.
buttons, text, images
Row, Column, Stack
StatefulWidget
screens & routes
make it pretty
real Flutter app
📌 All Dart you learned = the language. Flutter = the UI framework. Now you build.
"I don't know Dart" → learned basics
"Git scares me" → team collaboration
"Classes are hard" → advanced OOP
"API? What?" → live data apps
📌 7 days ago = zero. Today = can build real apps.
📌 Pick ONE project this week. Finish it. Share it.
Made it through 7 days of Dart.
Keep building. Ask questions. Share code.
Practice at dartpad.dev. Flutter next week. Come ready.