What it does
Demos is the app's table of contents: six studies, 24 Material demos, 13 Cupertino demos and 5 reference demos (colors, typography, motion, 2D transformations, two-pane), 81 configurations in all. Each GalleryDemo has a title, subtitle, icon, URL slug and category; each of its configurations has a title, a description, an API documentation URL, a buildRoute that builds the live widget and a code builder. The demo libraries are deferred imports, so buildRoute wraps the widget in a DeferredWidget that loads the library once, caches the future for everyone, and shows an empty placeholder until it arrives. The source shown in the code panel comes from CodeSegments, a 50,000-line file generated from the demo files at build time: one highlighted TextSpan builder per configuration (64 of them). One demo class usually serves several configurations through a type enum — ButtonDemo(type: ButtonDemoType.text) and four siblings share one file.