diff --git a/lib/main.dart b/lib/main.dart index d6a37ed..18d9879 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -20,6 +20,7 @@ class RandomWords extends StatefulWidget { class RandomWordsState extends State { final _suggestions = []; + final _saved = new Set(); final _biggerFont = const TextStyle(fontSize: 18.0); Widget _buildSuggestions() { @@ -39,11 +40,25 @@ class RandomWordsState extends State { } Widget _buildRow(WordPair pair) { + final alreadySaved = _saved.contains(pair); return new ListTile( title: new Text( pair.asPascalCase, style: _biggerFont, ), + trailing: new Icon( + alreadySaved ? Icons.favorite : Icons.favorite_border, + color: alreadySaved ? Colors.red : null, + ), + onTap: () { + setState(() { + if (alreadySaved) { + _saved.remove(pair); + } else { + _saved.add(pair); + } + }); + }, ); }