Commit ffad464c authored by Adam Barth's avatar Adam Barth

Merge pull request #877 from abarth/better_asserts

Improve asserts when performLayout missing
parents 4fa9e571 2edb6807
......@@ -564,11 +564,16 @@ abstract class RenderBox extends RenderObject {
assert(!size.isInfinite);
}
void performLayout() {
// descendants have to either override performLayout() to set both
// width and height and lay out children, or, set sizedByParent to
// true so that performResize()'s logic above does its thing.
assert(() {
if (!sizedByParent) {
debugPrint('$runtimeType needs to either override performLayout() to\n'
'set size and lay out children, or, set sizedByParent to true\n'
'so that performResize() sizes the render object.');
assert(sizedByParent);
}
return true;
});
}
/// Determines the set of render objects located at the given position
///
......@@ -581,6 +586,7 @@ abstract class RenderBox extends RenderObject {
/// whether the given position is within its bounds.
bool hitTest(HitTestResult result, { Point position }) {
assert(!needsLayout);
assert(_size != null && 'Missing size. Did you set a size during layout?' != null);
if (position.x >= 0.0 && position.x < _size.width &&
position.y >= 0.0 && position.y < _size.height) {
if (hitTestChildren(result, position: position) || hitTestSelf(position)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment