List: Rows from an Array
The scrolling workhorse
Almost every content screen in PawWalk is an array on display: walkers, bookings, pets, recent walks. SwiftUI's tool for that is List: hand it an array and a closure, and it turns every element into a scrollable row β List(walkers) { walker in β¦ }. The closure runs once per element and returns that element's row view.
You glimpsed exactly this in Module 05, inside WalkersView's .loaded case. Now the details. List does a lot for free: scrolling, row separators, and recycling β it only builds the rows currently on screen, so a thousand-walker list stays fast.
The one demand List makes: the elements must be Identifiable. This is the payoff of the id work from Modules 02β03 β when the array changes, List compares ids to know which rows appeared, moved, or vanished, and animates just those.