Commit e770b9da authored by Adam Barth's avatar Adam Barth

Merge pull request #552 from abarth/fix_image_layout

Images in Stocks drawer layout at crazy sizes
parents c25beb84 ae9f1702
...@@ -1385,6 +1385,9 @@ class RenderImage extends RenderBox { ...@@ -1385,6 +1385,9 @@ class RenderImage extends RenderBox {
} }
Size _sizeForConstraints(BoxConstraints constraints) { Size _sizeForConstraints(BoxConstraints constraints) {
if (constraints.isTight)
return constraints.constrain(Size.zero);
// If there's no image, we can't size ourselves automatically // If there's no image, we can't size ourselves automatically
if (_image == null) { if (_image == null) {
double width = _width == null ? 0.0 : _width; double width = _width == null ? 0.0 : _width;
...@@ -1392,7 +1395,6 @@ class RenderImage extends RenderBox { ...@@ -1392,7 +1395,6 @@ class RenderImage extends RenderBox {
return constraints.constrain(new Size(width, height)); return constraints.constrain(new Size(width, height));
} }
if (!constraints.isTight) {
// If neither height nor width are specified, use inherent image // If neither height nor width are specified, use inherent image
// dimensions. If only one dimension is specified, adjust the // dimensions. If only one dimension is specified, adjust the
// other dimension to maintain the aspect ratio. In both cases, // other dimension to maintain the aspect ratio. In both cases,
...@@ -1411,17 +1413,20 @@ class RenderImage extends RenderBox { ...@@ -1411,17 +1413,20 @@ class RenderImage extends RenderBox {
} }
return constraints.constrain(new Size(width, height)); return constraints.constrain(new Size(width, height));
} }
// Determine width from height // Determine width from height
double width = _height * _image.width / _image.height; double width = _height * _image.width / _image.height;
return constraints.constrain(new Size(width, height)); return constraints.constrain(new Size(width, height));
} }
if (_height == null) { if (_height == null) {
// Determine height from width // Determine height from width
double height = _width * _image.height / _image.width; double height = _width * _image.height / _image.width;
return constraints.constrain(new Size(width, height)); return constraints.constrain(new Size(width, height));
} }
}
return constraints.constrain(new Size(_image.width.toDouble(), _image.height.toDouble())); assert(_width != null && _height != null);
return constraints.constrain(new Size(_width, _height));
} }
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
......
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