Use code others already wrote. Save hours. Build real apps.
Press J anytime to jump to any section. Arrow keys to navigate.
Quick reminder of everything you already know.
abstract, base, interface, final
force children to fill methods
fixed family + exhaustive switch
smart object creation
share skills with with
add methods to built-ins
📌 Today: stop rewriting. Use existing code.
Like one book with ALL subjects. Math, science, history mixed. Can't find anything.
📌 Break big file into small files. Each file = one topic.
Like chapters in a book. Math chapter, science chapter. Find fast, organize easy.
📌 One concept = one file. One folder = one feature.
Every import is one of these three.
Files YOU write and split.
Already in Dart — FREE.
Shared by other devs.
📌 We'll cover all 3. Starting with your own files.
Like moving files to folders on your computer. One topic per folder.
📌 Rule: one concept = one file.
import — Two Ways📌 Small project → use relative. Big project → use package path.
import 'menu.dart'; — what does it do?import '../utils.dart'; means?.. goes up one folder. Just like the terminal!Hammer, screwdriver already inside. No buying. Just import 'dart:xxx'; and use.
Random, sqrt, pi
JSON, Base64
String, int (auto-imported)
files, network
Future, Stream (Day 7)
extra collections
📌 Just import 'dart:xxx'; — free, always there.
Like a dice. Roll → random number. dart:math gives you the dice.
📌 Random, sqrt, pi, pow — all need import 'dart:math';
Create Random() once, reuse.
nextInt(100) → 0..99 (not including 100).
Has sqrt, pi, pow, min, max.
Like a clock + calendar together. Knows current time + date.
📌 DateTime is auto-imported from dart:core. Free!
DateTime.now() for current time.
weekday: 1 = Mon, 7 = Sun.
.difference() returns a Duration.
'500' is a word. int.parse turns it into a number you can add, multiply, tax.
int.parse('500') → 500.
int.parse('abc') → crashes.
int.tryParse('abc') → null.
Like packing a box for shipping. Fold the object flat into text. Unpack later.
📌 JSON = standard text format for data. Used everywhere on the web.
📌 jsonEncode → text. jsonDecode → Map. Round trip!
Random().nextInt(10) returns?nextInt(n) returns 0 up to but not including n.int.parse('abc') does?int.parse throws on bad input. Use int.tryParse if unsure.jsonEncode?Like a supermarket for code. Someone already built it. Grab and use. Free.
📌 pub.dev has 100k+ packages. Someone already solved your problem.
Every Flutter dev lives here.
List packages under dependencies.
^1.0.0 = compatible updates allowed.
Run dart pub get.
Adds intl to pubspec.yaml.
Downloads package.
Use it!
📌 3 steps. Takes 10 seconds. Saves you hours.
^1.0.0 Meaning^1.2.3Means 1.2.3 up to <2.0.0.
Auto-updates that won't break your app.
Use 1.2.3 (no caret) to pin exactly.
make web requests
UI widgets
save settings
pick photos
GPS location
push notifs
📌 Need something? Search pub.dev FIRST. Don't reinvent.
pub.dev?^1.2.0 allows?dependencies section is where packages live.Everything from today — split files, dart:math, DateTime, JSON, intl. Click each feature.
Save code organized?
Random number?
Current time?
String → number?
Save as text?
Format money?
Web request?
Save settings?
import, relative paths
Random, sqrt, pi
now, difference, format
String → number
jsonEncode/Decode
shared packages
list packages
safe updates
format money/dates
menu.dart, order.dart, bill.dart, main.dart
dart:math
DateTime on each Order
dart:convert
intl package
Use branches! Create feature/your-name and submit a PR.
We'll make a real API call and get live data back. Finish today's assignment first!
📌 Save this slide. You'll use these commands every day.
Practice at dartpad.dev — add import lines at the top to pull in packages!