androidfluttermobile-developmentpopupmenubutton

Repositioning PopupMenuButton in flutter


i have try to create a popup menu button but i want to reposition the menu.

this is the code i've tried :

PopupMenuButton(itemBuilder: (context)=>[
        PopupMenuItem(child: Text("Grup Baru")),
        PopupMenuItem(child: Text("Siaran Baru")),
        PopupMenuItem(child: Text("Perangkat Tertaut")),
        PopupMenuItem(child: Text("Pesan Berbintang")),
      ])

and here's the result for default :

enter image description here

and i want to reposition it,

to this :

enter image description here

is there any suggest that i can try?


Solution

  • Add position: PopupMenuPosition.under, inside PopupMenuButton widget. Refer position and PopupMenuPosition

    under: Menu is positioned under the anchor.

    Full widget:

    PopupMenuButton(
            position: PopupMenuPosition.under,
            itemBuilder: (context) => [
              PopupMenuItem(child: Text("Grup Baru")),
              PopupMenuItem(child: Text("Siaran Baru")),
              PopupMenuItem(child: Text("Perangkat Tertaut")),
              PopupMenuItem(child: Text("Pesan Berbintang")),
            ],
          ),
    

    Result Screen: image