I am using PopupMenuButton in a flutter mobile app. I want to position the menu such that the calling button is centre aligned according to the screen. Below is how it currently shows on iPhone 12 Max Pro and iPhone 8. How can I get a consistent behaviour?
Updating the post to include code. I have tried to play around with the offset property however I couldn't figure out a way to correctly calculate the size of the popup menu once the button is pressed.
return PopupMenuButton(
elevation: 50,
color: Theme.of(context).colorScheme.button,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25),
),
child: SizedBox(
width: 162,
height: 49,
child: ClipRRect(
borderRadius: BorderRadius.circular(25),
child: Container(
color: Theme.of(context).colorScheme.button,
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
child: Row(
children: [
FaIcon(
FontAwesomeIcons.lightPlus,
color: Colors.white,
size: 16,
),
Spacer(),
Text("New", style: Theme.of(context).textTheme.whiteLabels),
Spacer(),
FaIcon(
FontAwesomeIcons.lightAngleUp,
color: Colors.white,
size: 20,
),
],
),
),
),
),
),
itemBuilder: (context) => [
PopupMenuItem(
value: 1,
child: Padding(
padding: const EdgeInsets.fromLTRB(8, 0, 0, 0),
child: Row(
children: [
FaIcon(
FontAwesomeIcons.lightEdit,
color: Colors.white,
size: 20,
),
Padding(
padding: const EdgeInsets.fromLTRB(12, 0, 0, 0),
child: Text('Type Text', style: Theme.of(context).textTheme.whiteLabels.copyWith(fontSize: 16)),
),
],
),
)),
PopupMenuItem(
value: 2,
child: Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 0, 0),
child: Row(
children: [
FaIcon(FontAwesomeIcons.lightMicrophone, color: Colors.white, size: 20),
Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 0, 0),
child: Text(' Record Voice', style: Theme.of(context).textTheme.whiteLabels.copyWith(fontSize: 16)),
),
],
),
)),
PopupMenuItem(
value: 3,
child: Padding(
padding: const EdgeInsets.fromLTRB(8, 0, 0, 0),
child: Row(
children: [
FaIcon(FontAwesomeIcons.lightCamera, color: Colors.white, size: 20),
Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 0, 0),
child: Text(' Take a Picture', style: Theme.of(context).textTheme.whiteLabels.copyWith(fontSize: 16)),
),
],
),
)),
PopupMenuItem(
value: 4,
child: Padding(
padding: const EdgeInsets.fromLTRB(8, 0, 0, 0),
child: Row(
children: [
FaIcon(FontAwesomeIcons.lightVideo, color: Colors.white, size: 20),
Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 0, 0),
child: Text(' Record a Video', style: Theme.of(context).textTheme.whiteLabels.copyWith(fontSize: 16)),
),
],
),
))
],
);


