-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add BuildContext.size as a convenience getter #6355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Developers need to get the size of the BuildContext sufficiently often that we should provide a convenient getter for the value. Having this getter is also an opportunity to catch common mistakes and provide useful error messages that guide developers towards better patterns. Fixes flutter#2321
|
LGTM |
| /// | ||
| /// This getter will only return a valid result if [findRenderObject] actually | ||
| /// returns a [RenderBox]. If [findRenderObject] returns a render object that | ||
| /// is not a subtype of [RenderBox] (e.g., [RenderView], this getter will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing )
| 'Cannot get size during build.\n' | ||
| 'The size of this render object has not yet been determined because ' | ||
| 'the framework is still in the process of building widgets, which ' | ||
| 'means the render tree for this frame has not youet been determined. ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
youet->yet
| throw new FlutterError( | ||
| 'Cannot get size without a render object.\n' | ||
| 'In order for an element to have a valid size, the element must have ' | ||
| 'an assoicated render object. This element does not have an assoicated ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
associated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
twice
| 'The size of this render object has not yet been determined because ' | ||
| 'this render object has not yet been through layout, which typically ' | ||
| 'means that the size getter was called too early in the pipeline ' | ||
| '(e.g., during the build pahse) before the framework has determined ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pahse -> phase
Contains the following changes: d80c1de (HEAD -> master, upstream/master) Roll src/third_party/skia ab3144c3abb9..656cefe65d62 (11 commits) (#6362) edf6249 Add pushOffset to SceneBuilder (#6349) 3a01f39 Change log level from ERROR to WARNING (#6361) 5ae4708 Roll src/third_party/skia 227d4e10276c..ab3144c3abb9 (11 commits) (#6360) 763627f Do not export libdart symbols (#6337) 3052dbd SystemNavigator.pop can pop w/o UINavigationController (#6341) 0c096f7 Roll src/third_party/skia b3e48afc936d..227d4e10276c (1 commits) (#6359) b8c2a17 Roll src/third_party/skia cfe1264d7465..b3e48afc936d (3 commits) (#6356) c589b31 Expose push/popRoute on FlutterViewController (#6347) 075b3fc Roll src/third_party/skia 5ea41fc89b26..cfe1264d7465 (1 commits) (#6355) 2dd9b99 Roll Dart to version 808ed6238b9262660e31ea826f7aea6cfa3a3493 (#6354) 5b79938 Dont make any binaries specify an X11 dependency. (#6353) 309ac4e V0.8.2 fix compile problem with xcode10 (#6339) 26fdd1e Roll src/third_party/skia 5767fc042834..5ea41fc89b26 (3 commits) (#6351) cc44ca5 Perform persistent cache stores on the IO thread outside the frame workload. (#6350) f2a3df9 Wire up the Skia persistent GPU related artifacts cache. (#6278)
Developers need to get the size of the BuildContext sufficiently often
that we should provide a convenient getter for the value. Having this
getter is also an opportunity to catch common mistakes and provide
useful error messages that guide developers towards better patterns.
Fixes #2321