below is my code i want to show menu when focus is in textfield widget and hide when leave textfield widget. butt when i do this multiple time. sometime menu never hide. how to resolve this issue
return CustomPopupMenu(
child: Container(
padding: EdgeInsets.only(right:10),
child:
Focus(
canRequestFocus: false,
onFocusChange: (focused) async{
if (!focused) {
_controller.hideMenu();
}
},
child:
TextField(
autofocus: true,
onTap: (){
_controller.showMenu();
},
onChanged: (vale){
// here i will load data from api
},)),
),
menuBuilder: () =>
ClipRRect(
borderRadius: BorderRadius.circular(10),
child:
Card(
elevation: 10,
child:
Container(
height: 200,
width: 250,
child:
SingleChildScrollView(child:
Padding(
padding: EdgeInsets.all(5),
child:
Container(
padding: EdgeInsets.all(5),
child:
Column(
],)
)
),)
),),
),
barrierColor: Colors.transparent,
pressType: PressType.singleClick,
verticalMargin: -10,
controller: _controller,
);