@@ -97,7 +97,43 @@ class _ExampleBrowserState extends State<ExampleBrowser> {
9797 final theme = Theme .of (context);
9898
9999 return AppBar (
100- title: _buildExampleDropdown (),
100+ title: _selectedExample != null
101+ ? Row (
102+ children: [
103+ if (_selectedExample! .icon != null ) ...[
104+ Icon (_selectedExample! .icon, size: 20 ),
105+ const SizedBox (width: 8 ),
106+ ],
107+ Expanded (
108+ child: Column (
109+ crossAxisAlignment: CrossAxisAlignment .start,
110+ mainAxisSize: MainAxisSize .min,
111+ children: [
112+ Text (
113+ _selectedExample! .title,
114+ style: theme.textTheme.titleSmall? .copyWith (
115+ fontWeight: FontWeight .w600,
116+ ),
117+ maxLines: 1 ,
118+ overflow: TextOverflow .ellipsis,
119+ ),
120+ if (_selectedExample! .description.isNotEmpty)
121+ Text (
122+ _selectedExample! .description,
123+ style: theme.textTheme.labelSmall? .copyWith (
124+ color: theme.colorScheme.onSurface.withValues (
125+ alpha: 0.7 ,
126+ ),
127+ ),
128+ maxLines: 1 ,
129+ overflow: TextOverflow .ellipsis,
130+ ),
131+ ],
132+ ),
133+ ),
134+ ],
135+ )
136+ : const Text ('Examples' ),
101137 leading: IconButton (
102138 icon: const Icon (Icons .menu),
103139 onPressed: () {
@@ -113,104 +149,6 @@ class _ExampleBrowserState extends State<ExampleBrowser> {
113149 );
114150 }
115151
116- Widget _buildExampleDropdown () {
117- final theme = Theme .of (context);
118-
119- // Build a list that includes both category headers and examples
120- final List <Map <String , dynamic >> allItems = [];
121-
122- for (final category in widget.categories) {
123- // Add category header
124- allItems.add ({'type' : 'category' , 'category' : category});
125-
126- // Add examples under this category
127- for (final example in category.examples) {
128- allItems.add ({
129- 'type' : 'example' ,
130- 'category' : category,
131- 'example' : example,
132- });
133- }
134- }
135-
136- // Find current index based on selected example
137- final currentIndex = allItems.indexWhere (
138- (item) =>
139- item['type' ] == 'example' &&
140- item['example' ] == _selectedExample &&
141- (item['category' ] as ExampleCategory ).id == _selectedCategoryId,
142- );
143-
144- return DropdownButton <int >(
145- value: currentIndex >= 0 ? currentIndex : null ,
146- isExpanded: true ,
147- underline: const SizedBox (),
148- dropdownColor: theme.colorScheme.surfaceContainerHigh,
149- style: theme.textTheme.titleSmall? .copyWith (
150- color: theme.colorScheme.onSurface,
151- fontWeight: FontWeight .w600,
152- ),
153- items: allItems.asMap ().entries.map ((entry) {
154- final item = entry.value;
155-
156- if (item['type' ] == 'category' ) {
157- // Category header - disabled
158- final category = item['category' ] as ExampleCategory ;
159- return DropdownMenuItem <int >(
160- value: entry.key,
161- enabled: false ,
162- child: Padding (
163- padding: const EdgeInsets .only (top: 8 , bottom: 4 ),
164- child: Text (
165- category.title.toUpperCase (),
166- style: theme.textTheme.labelSmall? .copyWith (
167- fontWeight: FontWeight .bold,
168- color: theme.colorScheme.primary,
169- letterSpacing: 0.5 ,
170- ),
171- ),
172- ),
173- );
174- } else {
175- // Regular example item
176- final example = item['example' ] as Example ;
177- return DropdownMenuItem <int >(
178- value: entry.key,
179- child: Padding (
180- padding: const EdgeInsets .only (left: 16 ),
181- child: Row (
182- children: [
183- if (example.icon != null ) ...[
184- Icon (example.icon, size: 16 ),
185- const SizedBox (width: 8 ),
186- ],
187- Expanded (
188- child: Text (
189- example.title,
190- style: theme.textTheme.bodyMedium,
191- overflow: TextOverflow .ellipsis,
192- ),
193- ),
194- ],
195- ),
196- ),
197- );
198- }
199- }).toList (),
200- onChanged: (index) {
201- if (index != null ) {
202- final item = allItems[index];
203- // Only handle example selections (categories are disabled)
204- if (item['type' ] == 'example' ) {
205- final category = item['category' ] as ExampleCategory ;
206- final example = item['example' ] as Example ;
207- _onExampleSelected (example, category.id);
208- }
209- }
210- },
211- );
212- }
213-
214152 Widget _buildDrawer () {
215153 return Drawer (
216154 child: ExampleNavigation (
0 commit comments