下拉菜单 showMenu
IconButton(
icon: Icon(Icons.more_horiz),
onPressed: (){
showMenu(
context:context,
position:RelativeRect.fromLTRB(600, 76, 10, 0) ,
items: [
PopupMenuItem(
child: Row(
children: <Widget>[
Icon(Icons.home),
Text("首页")
],
),
),
PopupMenuItem(
child: Row(
children: <Widget>[
Icon(Icons.search),
Text("搜索")
],
),
)
]
);
},
)
Flutter GestureDetector gesture events
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
// Navigator.of(context).pop();
},
child:Text("")
)
Flutter pop-up menu at the bottom
Note: By default showModalBottomSheet the bottom of the pop-up menu when clicking anywhere will disappear. This time we add a GestureDetector gesture events in the outer layer, so click returns false when clicked will not disappear.
showModalBottomSheet (
context: context,
builder: (context) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
// Navigator.of(context).pop();
},
onDoubleTap: () {
print("DoubleTap");
},
child: Container()
);
}
)