rameez khan
rameez khan

Reputation: 359

flutter show small popup on select below the icon

I need to show a popup below the icon like this

enter image description here

Mean when click on icon this type of popup I needed

I try to search answers but not found something like this

I am trying like this

appBar: AppBar(
    title: Text(widget.data['customerName']),
    actions: [
      GestureDetector(
        onTap: (){
          print('open');
          PopupMenuButton(
            initialValue: 2,
            child: Center(
                child: Text('click here')),
            itemBuilder: (context) {
              return List.generate(5, (index) {
                return PopupMenuItem(
                  value: index,
                  child: Text('button no $index'),
                );
              });
            },
          );     
        },
        child: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Icon(Icons.more_vert_outlined, color: Colors.white,),
        ),
      ),
    ],
  

),

But its not opening

Upvotes: 0

Views: 516

Answers (1)

Giorgi
Giorgi

Reputation: 137

                PopupMenuButton<String>(
                  padding: EdgeInsets.only(right: 10),
                  onSelected: handleClick,
                  itemBuilder: (BuildContext context) {
                    return {
                      'View Customer',
                    }.map((String choice) {
                      return PopupMenuItem<String>(
                        value: choice,
                        child: Text(choice),
                      );
                    }).toList();
                  })
     

    void handleClick(String value) {
          switch (value) {
            case 'View Customer':
              Navigator.of(context).push(MaterialPageRoute(
                  builder: (context) => CustomerScreen()));
          }
        }

Upvotes: 1

Related Questions