I have a Stack() widget that has a child Text() widget inside. I need that Text widget's center to be at [ left: 137, top: 201].
With Positioned(), I can only position the edges of the object. How can I position the Text widget's center? Is there a way to use the child widget's width / height to offset Positioned(), or some other way?
Stack(
children: [
...,
Positioned(
left: 137, // I want these coordinates to be the center
top: 201, // but they are the top left corner now
child: Text("20%")
)])
Wrapping the Text() widget with Center() doesn't seem to do anything?
I have a CustomPainter that draws graphics that is part of the same Stack(), and I can get the pixel coordinates of any painted point. I want to overlay text, and I want to be able to center the text on a specific point. In this picture I would like the "20%" text to be centered on the middle cross between green/blue (x: 137, y: 201), but I can only set the top left corner with Positioned()
Text
widget to be in the center of theStack
, I want the center of theText
widget to be in a certain (x, y) position. I just tested wrapping the widget withCenter
, didn't work. – ekuusi