Size _sizeForConstraints(BoxConstraints constraints) { constraints = BoxConstraints.tightFor( _width, _height ).enforce(constraints); if (_image == null) { return(constraints.smallest); } return(constraints.constrainSizeAndAttemptToPreserveAspectRatio(new Size( (_image.width / _scale), (_image.height / _scale) ))); }