From 947bcb5a7baa4e5281eb2b0d46e8e9b2352346db Mon Sep 17 00:00:00 2001 From: unknown <asdfqwer1234@ajou.ac.kr> Date: Tue, 24 Sep 2024 18:31:58 +0900 Subject: [PATCH] codelab8 --- lib/main.dart | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index caeb281..445b0eb 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -63,7 +63,7 @@ class _MyHomePageState extends State<MyHomePage> { page = GeneratorPage(); break; case 1: - page = Placeholder(); + page = FavoritesPage(); break; default: throw UnimplementedError('no widget for $selectedIndex'); @@ -180,4 +180,32 @@ class BigCard extends StatelessWidget { ), ); } +} + +class FavoritesPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + var appState = context.watch<MyAppState>(); + + if (appState.favorites.isEmpty) { + return Center( + child: Text('No favorites yet.'), + ); + } + + 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), + ), + ], + ); + } } \ No newline at end of file -- GitLab