Make UI react to data. Render lists. Stop hardcoding colors. Flip dark mode in one tap.
Press J to jump. Arrow keys to navigate.
You can build a screen now. But everything is hardcoded. Today: react to data.
Text, Container, Image
Row, Column, Stack
Redraw on change
Today → UI changes based on data. Different widgets for different states.
The simplest conditional UI. Pick one widget or another based on a bool.
Read it: "if logged in, show Home, else show Login." Common for auth flows.
Click below. Watch the whole card swap.
In Flutter: isLoggedIn ? Home() : Login()
Inside a Column or Row's children:, you can use if to include a widget — or skip it entirely.
No SizedBox.shrink(). No empty containers. Just include or skip.
Toggle the flag. The premium row appears or disappears.
You can also use ternary for properties. Color, size, anything.
Got a list of names? Use for right inside children:.
3 names → 3 Text widgets. Add a 4th name? 4 widgets. Automatic.
Same result. Different style. Functional flavor — like Dart's .map from Day 5.
โ ๏ธ Don't forget .toList() — .map returns an Iterable, but Column needs a List.
Cleaner. Reads like English.
Functional. Same as JS or Python.
In this course we'll mostly use collection-for. It's clearer.
Click to add. Watch the column grow. That's collection-for at work.
Column doesn't scroll. ListView does. Use it for anything taller than the screen.
Got 1000 items? Don't build them all at once. .builder creates rows only as you scroll.
Lazy. Only renders rows on screen. Scroll smoothly even with 10,000 items.
Few items, all at once.
Many items, lazy.
Default to .builder. It's faster and you can swap data in/out.
Don't show a blank screen. Combine ternary + ListView.
APIs return JSON. Parsed JSON = Maps. You'll see this everywhere.
The pattern you'll use 100x in real apps.
JSON sometimes has gaps. Use ?? to provide a fallback.
Reads as: "this value, or fallback if it's null." Saves you from crashes.
Hardcoded values everywhere = nightmare. Theme = define once, use everywhere.
Want to change brand color? Edit 47 files. ๐ญ
Change brand color? Edit 1 line. โจ
Pass a ThemeData to MaterialApp. Every widget below it picks it up.
fromSeed generates a full palette from one color. Material 3 magic.
Don't think "blue" or "red." Think purpose. Each role has a meaning.
Brand. Buttons. Links.
Accents. Floating buttons.
Cards. Sheets. Dialogs.
Failures. Validation.
App canvas.
Text on primary BG.
Inside any widget, ask the context for the theme. Then use the colors.
Same idea for fonts. Don't pick sizes by guess — use named roles.
Same UI. Half the code. Updates everywhere.
Pass theme AND darkTheme to MaterialApp. Then pick which to use.
.system follows the user's phone setting. Your app adapts automatically.
Click the toggle. Whole UI swaps. Zero hardcoded colors.
Colors.white breaks in dark mode. Use theme.
Logos with white BG look weird on dark. Use SVG.
Toggle every screen during dev. Catch contrast bugs.
If you used CupertinoApp on Day 8, theming is similar but separate. Skip if you're MaterialApp-only.
Most cross-platform apps stick with MaterialApp + dark mode. Cupertino theme = niche.
Combine everything. List of Maps + ListView.builder + conditional badge + theme.
Ternary, collection-if, conditional styling
collection-for, .map().toList()
.builder for big lists, empty states
JSON-shaped data, ?? for nulls
colorScheme, textTheme, fromSeed
theme + darkTheme + themeMode
Open DartPad or your editor. Ship it.
Day 10: navigation, multiple screens, passing data between pages. See you there.