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
71976b30
Commit
71976b30
authored
Mar 22, 2016
by
Hixie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix RenderFractionallySizedBox's constraints logic
Fixes
https://github.com/flutter/flutter/issues/2735
parent
b00cf22e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
13 deletions
+46
-13
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+13
-13
constraints_test.dart
packages/flutter/test/rendering/constraints_test.dart
+33
-0
No files found.
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
71976b30
...
...
@@ -247,15 +247,15 @@ class RenderConstrainedBox extends RenderProxyBox {
}
}
/// Sizes its
elf
to a fraction of the total available space.
/// Sizes its
child
to a fraction of the total available space.
///
/// For both its width and
width
height, this render object imposes a tight
/// For both its width and height, this render object imposes a tight
/// constraint on its child that is a multiple (typically less than 1.0) of the
/// maximum constraint it received from its parent on that axis. If the factor
/// for a given axis is null, then the constraints from the parent are just
/// passed through instead.
///
/// It then tries to size itself t the size of its child.
/// It then tries to size itself t
o
the size of its child.
class
RenderFractionallySizedBox
extends
RenderProxyBox
{
RenderFractionallySizedBox
({
RenderBox
child
,
...
...
@@ -323,41 +323,41 @@ class RenderFractionallySizedBox extends RenderProxyBox {
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
debugAssertIsNormalized
);
if
(
child
!=
null
)
return
c
hild
.
getMinIntrinsicWidth
(
_getInnerConstraints
(
constraints
));
return
_getInnerConstraints
(
constraints
).
constrainWidth
(
0.0
);
return
c
onstraints
.
constrainWidth
(
child
.
getMinIntrinsicWidth
(
_getInnerConstraints
(
constraints
)
));
return
constraints
.
constrainWidth
(
_getInnerConstraints
(
constraints
).
constrainWidth
(
0.0
)
);
}
@override
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
debugAssertIsNormalized
);
if
(
child
!=
null
)
return
c
hild
.
getMaxIntrinsicWidth
(
_getInnerConstraints
(
constraints
));
return
_getInnerConstraints
(
constraints
).
constrainWidth
(
0.0
);
return
c
onstraints
.
constrainWidth
(
child
.
getMaxIntrinsicWidth
(
_getInnerConstraints
(
constraints
)
));
return
constraints
.
constrainWidth
(
_getInnerConstraints
(
constraints
).
constrainWidth
(
0.0
)
);
}
@override
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
debugAssertIsNormalized
);
if
(
child
!=
null
)
return
c
hild
.
getMinIntrinsicHeight
(
_getInnerConstraints
(
constraints
));
return
_getInnerConstraints
(
constraints
).
constrainHeight
(
0.0
);
return
c
onstraints
.
constrainHeight
(
child
.
getMinIntrinsicHeight
(
_getInnerConstraints
(
constraints
)
));
return
constraints
.
constrainHeight
(
_getInnerConstraints
(
constraints
).
constrainHeight
(
0.0
)
);
}
@override
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
debugAssertIsNormalized
);
if
(
child
!=
null
)
return
c
hild
.
getMaxIntrinsicHeight
(
_getInnerConstraints
(
constraints
));
return
_getInnerConstraints
(
constraints
).
constrainHeight
(
0.0
);
return
c
onstraints
.
constrainHeight
(
child
.
getMaxIntrinsicHeight
(
_getInnerConstraints
(
constraints
)
));
return
constraints
.
constrainHeight
(
_getInnerConstraints
(
constraints
).
constrainHeight
(
0.0
)
);
}
@override
void
performLayout
()
{
if
(
child
!=
null
)
{
child
.
layout
(
_getInnerConstraints
(
constraints
),
parentUsesSize:
true
);
size
=
c
hild
.
size
;
size
=
c
onstraints
.
constrain
(
child
.
size
)
;
}
else
{
size
=
_getInnerConstraints
(
constraints
).
constrain
(
Size
.
zero
);
size
=
constraints
.
constrain
(
_getInnerConstraints
(
constraints
).
constrain
(
Size
.
zero
)
);
}
}
...
...
packages/flutter/test/rendering/constraints_test.dart
0 → 100644
View file @
71976b30
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/rendering.dart'
;
import
'package:test/test.dart'
;
import
'rendering_tester.dart'
;
void
main
(
)
{
test
(
"RenderFractionallySizedBox constraints"
,
()
{
RenderBox
root
,
leaf
,
test
;
root
=
new
RenderPositionedBox
(
child:
new
RenderConstrainedBox
(
additionalConstraints:
new
BoxConstraints
.
tight
(
const
Size
(
200.0
,
200.0
)),
child:
test
=
new
RenderFractionallySizedBox
(
widthFactor:
2.0
,
heightFactor:
0.5
,
child:
leaf
=
new
RenderConstrainedBox
(
additionalConstraints:
const
BoxConstraints
.
expand
()
)
)
)
);
layout
(
root
);
expect
(
root
.
size
.
width
,
equals
(
800.0
));
expect
(
root
.
size
.
height
,
equals
(
600.0
));
expect
(
test
.
size
.
width
,
equals
(
200.0
));
expect
(
test
.
size
.
height
,
equals
(
200.0
));
expect
(
leaf
.
size
.
width
,
equals
(
400.0
));
expect
(
leaf
.
size
.
height
,
equals
(
100.0
));
});
}
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