diff --git a/lib/main.dart b/lib/main.dart index 391343ba790ffc7ebe3f2f175350d3b7df59180d..3490d952cc152806b5e6d708039867088151db23 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) {