Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
e770b9da
Commit
e770b9da
authored
Aug 11, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #552 from abarth/fix_image_layout
Images in Stocks drawer layout at crazy sizes
parents
c25beb84
ae9f1702
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
26 deletions
+31
-26
box.dart
packages/flutter/lib/rendering/box.dart
+31
-26
No files found.
packages/flutter/lib/rendering/box.dart
View file @
e770b9da
...
...
@@ -1385,6 +1385,9 @@ class RenderImage extends RenderBox {
}
Size
_sizeForConstraints
(
BoxConstraints
constraints
)
{
if
(
constraints
.
isTight
)
return
constraints
.
constrain
(
Size
.
zero
);
// If there's no image, we can't size ourselves automatically
if
(
_image
==
null
)
{
double
width
=
_width
==
null
?
0.0
:
_width
;
...
...
@@ -1392,36 +1395,38 @@ class RenderImage extends RenderBox {
return
constraints
.
constrain
(
new
Size
(
width
,
height
));
}
if
(!
constraints
.
isTight
)
{
// If neither height nor width are specified, use inherent image
// dimensions. If only one dimension is specified, adjust the
// other dimension to maintain the aspect ratio. In both cases,
// constrain dimensions first, otherwise we end up losing the
// ratio after constraining.
if
(
_width
==
null
)
{
if
(
_height
==
null
)
{
// autosize
double
width
=
constraints
.
constrainWidth
(
_image
.
width
.
toDouble
());
double
maxHeight
=
constraints
.
constrainHeight
(
_image
.
height
.
toDouble
());
double
ratio
=
_image
.
height
/
_image
.
width
;
double
height
=
width
*
ratio
;
if
(
height
>
maxHeight
)
{
height
=
maxHeight
;
width
=
maxHeight
/
ratio
;
}
return
constraints
.
constrain
(
new
Size
(
width
,
height
));
}
// Determine width from height
double
width
=
_height
*
_image
.
width
/
_image
.
height
;
return
constraints
.
constrain
(
new
Size
(
width
,
height
));
}
// If neither height nor width are specified, use inherent image
// dimensions. If only one dimension is specified, adjust the
// other dimension to maintain the aspect ratio. In both cases,
// constrain dimensions first, otherwise we end up losing the
// ratio after constraining.
if
(
_width
==
null
)
{
if
(
_height
==
null
)
{
// Determine height from width
double
height
=
_width
*
_image
.
height
/
_image
.
width
;
// autosize
double
width
=
constraints
.
constrainWidth
(
_image
.
width
.
toDouble
());
double
maxHeight
=
constraints
.
constrainHeight
(
_image
.
height
.
toDouble
());
double
ratio
=
_image
.
height
/
_image
.
width
;
double
height
=
width
*
ratio
;
if
(
height
>
maxHeight
)
{
height
=
maxHeight
;
width
=
maxHeight
/
ratio
;
}
return
constraints
.
constrain
(
new
Size
(
width
,
height
));
}
// Determine width from height
double
width
=
_height
*
_image
.
width
/
_image
.
height
;
return
constraints
.
constrain
(
new
Size
(
width
,
height
));
}
return
constraints
.
constrain
(
new
Size
(
_image
.
width
.
toDouble
(),
_image
.
height
.
toDouble
()));
if
(
_height
==
null
)
{
// Determine height from width
double
height
=
_width
*
_image
.
height
/
_image
.
width
;
return
constraints
.
constrain
(
new
Size
(
width
,
height
));
}
assert
(
_width
!=
null
&&
_height
!=
null
);
return
constraints
.
constrain
(
new
Size
(
_width
,
_height
));
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment