I created a list containing PopupMenuButton using ListView.builder.
And I set the offset to open the popup menu at the desired position in this PopupMenuButton.
However, the popup menu only opens at the offset zero or end of the Row.
return ListView.separated(
itemBuilder: (context, index) {
// popupmenu button widget (list first index)
if (index == 0) {
return _buildNewRoom();
}
// other widget
return _buildMyRooms(
widget.roomModels[index - 1],
index,
_controllers[index],
);
},
separatorBuilder: (context, index) {
return const Divider(
color: Colors.grey,
);
},
itemCount: widget.roomModels.length + 1,
);
// _buildNewRoom (popup menu widget)
class CreateMenuWidget extends StatelessWidget {
final bool isTablet;
final bool isListStyle1;
const CreateMenuWidget({
Key? key,
required this.isTablet,
required this.isListStyle1,
}) : super(key: key);
@override
Widget build(BuildContext context) {
double _containerWidth = 50;
double _containerHeight = 70;
return PopupMenuButton<int>(
color: Colors.grey[100],
offset: const Offset(0, 100), // offset X problem??
constraints: BoxConstraints(
minWidth: 200,
),
itemBuilder: _itemList,
onSelected: _onSeleted,
child: ListTile(
title: Row(
children: [
Container(
width: _containerWidth,
height: _containerHeight,
decoration: BoxDecoration(
border: Border.all(
color: Colors.blue,
width: 2.0,
),
borderRadius: const BorderRadius.all(
Radius.circular(10),
),
),
child: const Center(
child: Icon(
Icons.add,
color: Colors.blue,
size: 28,
),
),
),
SizedBox(
width: sm_padding,
),
const Text(
"New File",
style: TextStyle(
color: Colors.blue,
fontSize: 17,
),
),
],
),
),
);
}
}
Offset Y works well, but if offset X is greater than 0, it will always be at the end of the ListTile
Offset(0,100)
Offset(1,100) or Or a larger value
Why is the popup menu positioned at the end of ListTile?

