center property
Offset
center
Returns the global center of the node.
Implementation
Offset get center {
var paintBounds = rect;
SemanticsNode? current = this;
while (current != null) {
final transform = current.transform;
if (transform != null) {
paintBounds = MatrixUtils.transformRect(transform, paintBounds);
}
current = current.parent;
}
final devicePixelRatio =
WidgetsBinding.instance.platformDispatcher.views.first.devicePixelRatio;
return MatrixUtils.transformRect(
Matrix4.diagonal3Values(
1.0 / devicePixelRatio,
1.0 / devicePixelRatio,
1.0 / devicePixelRatio,
),
paintBounds,
).center;
}