Created
March 17, 2021 20:18
-
-
Save bistole/adf512d71bdf23fcbfc14dd4d7b01e6b to your computer and use it in GitHub Desktop.
get rect from rendered widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rect getRectFromWidget(GlobalKey gKey) { | |
final keyContext = gKey.currentContext; | |
if (keyContext != null) { | |
final box = keyContext.findRenderObject() as RenderBox; | |
final offset = box.localToGlobal(Offset.zero); | |
final size = box.hasSize ? box.size : Size.zero; | |
return Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height); | |
} | |
return Rect.zero; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment