Responding to mouse events in Flutter Desktop
While, with mobile devices, users generally interact with your apps through touch gestures, with bigger devices, they may use a mouse, and from a developer perspective, mouse input is different from touch.
In this recipe, you will learn how to respond to common mouse gestures such as click and right-click. In particular, you will make the user select and deselect items in a GridView
, and change the color of the background to give some feedback to your users.
Getting ready
Before following this recipe, you should have completed the first recipe in this chapter, Creating a responsive app leveraging Flutter Web.
How to do it…
In order to respond to mouse gestures within your app, please follow these steps:
- Open the
book_list_screen.dart
file in your project. - At the top of the
_BookListScreenState
class, add a newColor list
, calledbgColors
, and set it to an emptyList
:List<Color>...