custom_pop_up_menu
custom_pop_up_menu copied to clipboard
On TextField Widget want to show menu on focus and hide on leave butt not working fine
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(
// color:Colors.black54,
height: 200,
width: 250,
child:
SingleChildScrollView(child:
Padding(
padding: EdgeInsets.all(5),
child:
Container(
padding: EdgeInsets.all(5),
child:
Column(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('hello')
],)
)
),)
),),
),
barrierColor: Colors.transparent,
pressType: PressType.singleClick,
verticalMargin: -10,
controller: _controller,
);
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(
// color:Colors.black54,
height: 200, width: 250, child: SingleChildScrollView(child: Padding( padding: EdgeInsets.all(5), child: Container( padding: EdgeInsets.all(5), child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('hello')
],) ) ),) ),), ), barrierColor: Colors.transparent, pressType: PressType.singleClick, verticalMargin: -10, controller: _controller, );
so you want to implement the input suggestion?
Yes
i'm interested to this answer? i had same problem ?