Answers for "get position of a widget in screen flutter"

3

get position of a widget in screen flutter

extension GlobalKeyEx on GlobalKey {
  Rect get globalPaintBounds {
    final renderObject = currentContext?.findRenderObject();
    var translation = renderObject?.getTransformTo(null)?.getTranslation();
    if (translation != null && renderObject.paintBounds != null) {
      return renderObject.paintBounds
          .shift(Offset(translation.x, translation.y));
    } else {
      return null;
    }
  }
}
Posted by: Guest on July-10-2020

Code answers related to "get position of a widget in screen flutter"

Browse Popular Code Answers by Language