There are a few ways to approximate the centroid of a polygon.
The easiest (but least accurate method) is to get the center of the bounding box that contains the polygon, as yarl suggested, using.
I have widgets in a stack so i'd like to position my button bar in the bottom center of the stack but nothing works.
The widget just sticks to the left side.
Here is my code.