I’m working on a flutter web application and I have used a DropdownButton widget as top menu on my site. How can i open the dropdown button upon a mouse hover. Below is my dropdown button
DropdownButton(
value: teachingsDropdownValue,
icon: SizedBox.shrink(),
focusColor: Colors.white,
elevation: 0,
onTap: (){},
underline: Container(
height: 2,
color: Colors.white,
),
items: teachingsItems.map((String items) {
return DropdownMenuItem(
value: items,
child: Text(items,textAlign: TextAlign.center,),
);
}).toList(),
onChanged: (String? newValue) {
setState(() {
// teachingsDropdownValue = newValue!;
if(newValue == "Salivation"){
Navigator.of(context).push(MaterialPageRoute(builder: (context) => TeachingsSalivationScreen()));
}
});
},
),
2
Answers
Result
Explanation
There are two steps that you need:
Detect the hover.
Open the
Dropdown
.To detect a hover, use
MouseRegion
‘sonHover
Then, to open the drawer, you can use the code from
Code
Here’s a complete working snippet:
Just uset hover_menu: ^1.1.1