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
57dd51a3
Unverified
Commit
57dd51a3
authored
May 03, 2018
by
Ian Hickson
Committed by
GitHub
May 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix documentation for UnconstrainedBox and code cleanup (#17249)
parent
916ed6c4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
29 deletions
+29
-29
shifted_box.dart
packages/flutter/lib/src/rendering/shifted_box.dart
+15
-24
stack.dart
packages/flutter/lib/src/rendering/stack.dart
+6
-0
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+8
-5
No files found.
packages/flutter/lib/src/rendering/shifted_box.dart
View file @
57dd51a3
...
@@ -484,7 +484,6 @@ class RenderPositionedBox extends RenderAligningShiftedBox {
...
@@ -484,7 +484,6 @@ class RenderPositionedBox extends RenderAligningShiftedBox {
/// * [RenderSizedOverflowBox], a render object that is a specific size but
/// * [RenderSizedOverflowBox], a render object that is a specific size but
/// passes its original constraints through to its child, which it allows to
/// passes its original constraints through to its child, which it allows to
/// overflow.
/// overflow.
class
RenderConstrainedOverflowBox
extends
RenderAligningShiftedBox
{
class
RenderConstrainedOverflowBox
extends
RenderAligningShiftedBox
{
/// Creates a render object that lets its child overflow itself.
/// Creates a render object that lets its child overflow itself.
RenderConstrainedOverflowBox
({
RenderConstrainedOverflowBox
({
...
@@ -584,10 +583,11 @@ class RenderConstrainedOverflowBox extends RenderAligningShiftedBox {
...
@@ -584,10 +583,11 @@ class RenderConstrainedOverflowBox extends RenderAligningShiftedBox {
/// render at its "natural" size.
/// render at its "natural" size.
///
///
/// This allows a child to render at the size it would render if it were alone
/// This allows a child to render at the size it would render if it were alone
/// on an infinite canvas with no constraints. This box will then expand
/// on an infinite canvas with no constraints. This box will then attempt to
/// as much as it can within its own constraints and align the child based on
/// adopt the same size, within the limits of its own constraints. If it ends
/// [alignment]. If the box cannot expand enough to accommodate the entire
/// up with a different size, it will align the child based on [alignment].
/// child, the child will be clipped.
/// If the box cannot expand enough to accommodate the entire child, the
/// child will be clipped.
///
///
/// In debug mode, if the child overflows the box, a warning will be printed on
/// In debug mode, if the child overflows the box, a warning will be printed on
/// the console, and black and yellow striped areas will appear where the
/// the console, and black and yellow striped areas will appear where the
...
@@ -595,9 +595,9 @@ class RenderConstrainedOverflowBox extends RenderAligningShiftedBox {
...
@@ -595,9 +595,9 @@ class RenderConstrainedOverflowBox extends RenderAligningShiftedBox {
///
///
/// See also:
/// See also:
///
///
/// * [RenderConstrainedBox]
renders a box which imposes constraints on i
ts
/// * [RenderConstrainedBox]
, which renders a box which imposes constrain
ts
/// child.
///
on its
child.
/// * [RenderConstrainedOverflowBox], renders a box that imposes different
/// * [RenderConstrainedOverflowBox],
which
renders a box that imposes different
/// constraints on its child than it gets from its parent, possibly allowing
/// constraints on its child than it gets from its parent, possibly allowing
/// the child to overflow the parent.
/// the child to overflow the parent.
/// * [RenderSizedOverflowBox], a render object that is a specific size but
/// * [RenderSizedOverflowBox], a render object that is a specific size but
...
@@ -641,40 +641,31 @@ class RenderUnconstrainedBox extends RenderAligningShiftedBox with DebugOverflow
...
@@ -641,40 +641,31 @@ class RenderUnconstrainedBox extends RenderAligningShiftedBox with DebugOverflow
if
(
child
!=
null
)
{
if
(
child
!=
null
)
{
// Let the child lay itself out at it's "natural" size, but if
// Let the child lay itself out at it's "natural" size, but if
// constrainedAxis is non-null, keep any constraints on that axis.
// constrainedAxis is non-null, keep any constraints on that axis.
BoxConstraints
childConstraints
;
if
(
constrainedAxis
!=
null
)
{
if
(
constrainedAxis
!=
null
)
{
switch
(
constrainedAxis
)
{
switch
(
constrainedAxis
)
{
case
Axis
.
horizontal
:
case
Axis
.
horizontal
:
child
.
layout
(
new
BoxConstraints
(
childConstraints
=
new
BoxConstraints
(
maxWidth:
constraints
.
maxWidth
,
minWidth:
constraints
.
minWidth
);
maxWidth:
constraints
.
maxWidth
,
minWidth:
constraints
.
minWidth
),
parentUsesSize:
true
,
);
break
;
break
;
case
Axis
.
vertical
:
case
Axis
.
vertical
:
child
.
layout
(
new
BoxConstraints
(
childConstraints
=
new
BoxConstraints
(
maxHeight:
constraints
.
maxHeight
,
minHeight:
constraints
.
minHeight
);
maxHeight:
constraints
.
maxHeight
,
minHeight:
constraints
.
minHeight
),
parentUsesSize:
true
,
);
break
;
break
;
}
}
}
else
{
}
else
{
child
.
layout
(
const
BoxConstraints
(),
parentUsesSize:
true
);
child
Constraints
=
const
BoxConstraints
(
);
}
}
child
.
layout
(
childConstraints
,
parentUsesSize:
true
);
size
=
constraints
.
constrain
(
child
.
size
);
size
=
constraints
.
constrain
(
child
.
size
);
alignChild
();
alignChild
();
final
BoxParentData
childParentData
=
child
.
parentData
;
final
BoxParentData
childParentData
=
child
.
parentData
;
_overflowContainerRect
=
Offset
.
zero
&
size
;
_overflowContainerRect
=
Offset
.
zero
&
size
;
_overflowChildRect
=
childParentData
.
offset
&
child
.
size
;
_overflowChildRect
=
childParentData
.
offset
&
child
.
size
;
}
else
{
}
else
{
size
=
constraints
.
constrain
(
Size
.
zero
)
;
size
=
constraints
.
smallest
;
_overflowContainerRect
=
Rect
.
zero
;
_overflowContainerRect
=
Rect
.
zero
;
_overflowChildRect
=
Rect
.
zero
;
_overflowChildRect
=
Rect
.
zero
;
}
}
_isOverflowing
=
new
RelativeRect
.
fromRect
(
_overflowContainerRect
,
_overflowChildRect
).
hasInsets
;
final
RelativeRect
overflow
=
new
RelativeRect
.
fromRect
(
_overflowContainerRect
,
_overflowChildRect
);
_isOverflowing
=
overflow
.
left
>
0.0
||
overflow
.
right
>
0.0
||
overflow
.
top
>
0.0
||
overflow
.
bottom
>
0.0
;
}
}
@override
@override
...
...
packages/flutter/lib/src/rendering/stack.dart
View file @
57dd51a3
...
@@ -77,6 +77,12 @@ class RelativeRect {
...
@@ -77,6 +77,12 @@ class RelativeRect {
/// May be negative if the bottom side of the rectangle is outside of the container.
/// May be negative if the bottom side of the rectangle is outside of the container.
final
double
bottom
;
final
double
bottom
;
/// Returns whether any of the values are greater than zero.
///
/// This corresponds to one of the sides ([left], [top], [right], or [bottom]) having
/// some positive inset towards the center.
bool
get
hasInsets
=>
left
>
0.0
||
top
>
0.0
||
right
>
0.0
||
bottom
>
0.0
;
/// Returns a new rectangle object translated by the given offset.
/// Returns a new rectangle object translated by the given offset.
RelativeRect
shift
(
Offset
offset
)
{
RelativeRect
shift
(
Offset
offset
)
{
return
new
RelativeRect
.
fromLTRB
(
left
+
offset
.
dx
,
top
+
offset
.
dy
,
right
-
offset
.
dx
,
bottom
-
offset
.
dy
);
return
new
RelativeRect
.
fromLTRB
(
left
+
offset
.
dx
,
top
+
offset
.
dy
,
right
-
offset
.
dx
,
bottom
-
offset
.
dy
);
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
57dd51a3
...
@@ -1775,10 +1775,11 @@ class ConstrainedBox extends SingleChildRenderObjectWidget {
...
@@ -1775,10 +1775,11 @@ class ConstrainedBox extends SingleChildRenderObjectWidget {
/// at its "natural" size.
/// at its "natural" size.
///
///
/// This allows a child to render at the size it would render if it were alone
/// This allows a child to render at the size it would render if it were alone
/// on an infinite canvas with no constraints. This container will then expand
/// on an infinite canvas with no constraints. This container will then attempt
/// as much as it can within its own constraints and align the child based on
/// to adopt the same size, within the limits of its own constraints. If it ends
/// [alignment]. If the container cannot expand enough to accommodate the
/// up with a different size, it will align the child based on [alignment].
/// entire child, the child will be clipped.
/// If the box cannot expand enough to accommodate the entire child, the
/// child will be clipped.
///
///
/// In debug mode, if the child overflows the container, a warning will be
/// In debug mode, if the child overflows the container, a warning will be
/// printed on the console, and black and yellow striped areas will appear where
/// printed on the console, and black and yellow striped areas will appear where
...
@@ -1786,7 +1787,9 @@ class ConstrainedBox extends SingleChildRenderObjectWidget {
...
@@ -1786,7 +1787,9 @@ class ConstrainedBox extends SingleChildRenderObjectWidget {
///
///
/// See also:
/// See also:
///
///
/// * [ConstrainedBox] for a box which imposes constraints on its child.
/// * [ConstrainedBox], for a box which imposes constraints on its child.
/// * [Align], which loosens the constraints given to the child rather than
/// removing them entirely.
/// * [Container], a convenience widget that combines common painting,
/// * [Container], a convenience widget that combines common painting,
/// positioning, and sizing widgets.
/// positioning, and sizing widgets.
/// * [OverflowBox], a widget that imposes different constraints on its child
/// * [OverflowBox], a widget that imposes different constraints on its child
...
...
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