Components

 For Add the popup menu button on app bar:

first declare the under the appBar: action:<Widget>[
PopupMenuButton<int>(
    icon: Icon(
      Icons.sort,
      color: Colors.white,
    ),
    onSelected: menuItemSelected,
    itemBuilder: (BuildContext context) => <PopupMenuItem<int>>[
          PopupMenuItem(
            value: 0,
            child: Row(
              children: <Widget>[
                Icon(
                  Icons.open_in_browser,
                  color: Colors.black,
                ),
                SizedBox(
                  width: 5.0,
                ),
                Text('Sort')
              ],
            ),
          ),
          PopupMenuItem(
            value: 1,
            child: Row(
              children: <Widget>[
                Icon(
                  Icons.person,
                  color: Colors.black,
                ),
                SizedBox(
                  width: 5.0,
                ),
                Text('Logout')
              ],
            ),
          ),
        ])
]
declare like it and for its properties onSeleted declare the menuItemSelected in a function like
this
 void menuItemSelected(int index) {
    switch (index) {
      case 0:
        _sortBy(context);
        break;
      case 1:
        Navigator.push(context,
            MaterialPageRoute(builder: (BuildContext context) => MyApp()));
//        //  _bottomSheet(context);))        break;
    }
  }


and perform the operation accordingly

Like if you want to open bottom sheet on the first seletion then here create _sortBy(context) then you
declare a method outside Scaffold upper context like
void _sortBy(context) {
    print("sort by pressed");
    showModalBottomSheet(
        context: context,
        builder: (BuildContext builder) {
          return Container(
            child: Wrap(
              children: <Widget>[
                ListTile(
                  title: Text(
                    "Projects",
                    style: TextStyle(fontSize: 14),
                  ),
 
                  },
                ),
                Divider(),
                ListTile(
                  title: Text("Sort by", style: TextStyle(fontSize: 14)),
                ),
                Padding(
                  padding: const EdgeInsets.all(10.0),
                  child: Card(
                    child: Column(
                      children: <Widget>[
                        ListTile(
                          title: Text("Title", style: TextStyle(fontSize: 14)),
                          trailing: Icon(Icons.done),
                          onTap: () {

                          },
                        ),
                        ListTile(
                          title: Text("Creation Date",
                              style: TextStyle(fontSize: 14)),
                          trailing: Icon(Icons.done),
                          onTap: () {

                          },
                        ),
                      ],
                    ),
                  ),
                ),
              ],
            ),
          );
        });
  }
}

Comments