Completing the UI of the app

On the home page of the app, we already have an IconButton that the user can press to add a book to their favorites. We only need to connect it to the addFavorites() method in the BooksHelper class to make it work. Let's look at the steps to do that here:

  1. Get to the ui.dart file, and in the BooksTable class in the build() method, in the last TableCell, edit the IconButton so that in the onPressed() method, it can add (or remove) a book in the favorites list, as follows:
child: IconButton(    color: (isFavorite) ? Colors.red : Colors.amber,     tooltip: (isFavorite) ? 'Remove from favorites' :   'Add to favorites',     icon: Icon(Icons.star),     onPressed: () {       if (isFavorite) {  helper.removeFromFavorites(book, context); ...

Get Flutter Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.