22

Is there any way I could create custom pop up with rounded borders? This is my current code and design:

                child: Container(
                 child: PopupMenuButton(
                   onSelected: _savedLocationOptionSelected,
                   itemBuilder: (context) {
                     return SavedLocationOptions.choises.map((value) {
                       return PopupMenuItem<String>(
                         value: value,
                         child: Text(value),
                       );
                     }).toList();
                   },
                   icon: Icon(
                     Icons.more_vert,
                     color: Colors.grey[300],
                   ),
                 ),
               ),

enter image description here

Mārtiņš Ciekurs
  • 437
  • 1
  • 6
  • 25

4 Answers4

41

You just add like this at PopupMenuButton

shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.all(
               Radius.circular(20.0),
          ),
),

Example

   PopupMenuButton(
      child: Text("Show Popup Menu"),
      shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.all(Radius.circular(15.0))
      ),
      itemBuilder: (context) => [
        PopupMenuItem(
          child: Text("pub.dev"),
        ),
        PopupMenuItem(
          child: Text("Flutter"),
        ),
        PopupMenuItem(
          child: Text("Google.com"),
        ),
        PopupMenuItem(
          child: Text("https://blogdeveloperspot.blogspot.com"),
        ),
      ],
    ),
Taz
  • 1,737
  • 1
  • 15
  • 30
4

Adding to the answer given by @Taz You can use themes to have settings for rounded corners in each and every Popups at one place:

MaterialApp(
  // ....
  theme: ThemeData(
  // ....
  popupMenuTheme: PopupMenuThemeData(
    shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))
  )
)
DrGeneral
  • 1,844
  • 1
  • 16
  • 22
2

Another simple way is:

shape: ContinuousRectangleBorder(
         borderRadius: BorderRadius.circular(30),
       ),
wahid anvary
  • 392
  • 3
  • 11
-2

Click Right on "PopupMenuButton" in your code then Paste it in The Page will Opend Named By "PopupMenu" and Paste the Code in This Link to Dart File

Then Visit this Link : enter image description herehttps://github.com/mohamedashraf8850/flutter/edit/master/packages/flutter/lib/src/material/popup_menu.dart

Muhammad Ashraf
  • 3,323
  • 2
  • 12
  • 19