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) {
var appState = context.watch<MyAppState>();
var textFields = <Text>[];
for (var fave in appState.favorites) {
textFields.add(Text(fave.toString()));
if (appState.favorites.isEmpty) {
return Center(
child: Text('No favorites yet.'),
);
}
return Center(
child: ListView(
children: textFields,
),
return ListView(
children: [
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),
),
],
);
}
}