Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On TextField Widget want to show menu on focus and hide on leave butt not working fine #16

Open
abdulrehmananwar opened this issue Mar 8, 2022 · 4 comments

Comments

@abdulrehmananwar
Copy link

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,
);
@malikwang
Copy link
Owner

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?

@abdulrehmananwar
Copy link
Author

Yes

@malikwang
Copy link
Owner

Yes

u can send demo to my email [email protected]

@biloo-dev
Copy link

i'm interested to this answer? i had same problem ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants