From 6bb469923b4196c74969e780d275f20678822157 Mon Sep 17 00:00:00 2001 From: RyuZU <dbrua1222@naver.com> Date: Wed, 5 Jun 2024 19:18:39 +0900 Subject: [PATCH] 8 --- lib/main.dart | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index 391343b..3490d95 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 = FavoritePage(); break; default: throw UnimplementedError('no widget for $selectedIndex'); @@ -108,6 +108,30 @@ class _MyHomePageState extends State<MyHomePage> { } } +class FavoritePage 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), + ), + ], + ); + } +} + class GeneratorPage extends StatelessWidget { @override Widget build(BuildContext context) { -- GitLab