In order to respond to mouse gestures within your app, please follow the next steps:
- Open the book_list_screen.dart file in your project.
- At the top of the _BookListScreenState class, add a new List of Color, called bgColors, and set it to an empty List:
List<Color> bgColors = [];
- In the initState method, in the then callback of the getFlutterBook method, add a for cycle that adds a new color (white) for each item in the List of books that was retrieved by the method:
helper.getBooks('flutter').then((List<Book> value) {
int i;
for (i = 0; i < value.length; i++) {
bgColors.add(Colors.white);
}
- At the bottom of the _BookListScreenState class, add a new method, called setColor, that takes a Color and an integer, called index, and sets the value of the bgColors list at the index position to the color that was passed:
void setColor(Color color, int index) {
setState(() {
bgColors[index] = color;
});
}
- In the build method...