Tutorial's version of the page.

This commit is contained in:
Hyperling 2025-01-30 12:35:35 -07:00
parent acb6ed8599
commit fe15a0edad

View File

@ -119,15 +119,25 @@ class FavoritesPage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
var appState = context.watch<MyAppState>(); var appState = context.watch<MyAppState>();
var textFields = <Text>[]; if (appState.favorites.isEmpty) {
for (var fave in appState.favorites) { return Center(
textFields.add(Text(fave.toString())); child: Text('No favorites yet.'),
);
} }
return Center( return ListView(
child: ListView( children: [
children: textFields, Padding(
padding: const EdgeInsets.all(20),
child: Text('You have '
'${appState.favorites.length} favorites:'),
), ),
for (var pair in appState.favorites)
ListTile(
leading: Icon(Icons.favorite),
title: Text(pair.asLowerCase),
),
],
); );
} }
} }