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
502f734d
Commit
502f734d
authored
May 26, 2016
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename FractionallySizedBox box size factor parameters (#4212)
parent
21fa2753
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
23 deletions
+31
-23
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+29
-21
fractionally_sized_box_test.dart
...ages/flutter/test/widget/fractionally_sized_box_test.dart
+2
-2
No files found.
packages/flutter/lib/src/widgets/basic.dart
View file @
502f734d
...
...
@@ -474,22 +474,27 @@ class Padding extends SingleChildRenderObjectWidget {
}
}
/// Aligns its child box within itself.
/// Aligns its child within itself and optionally sizes itself based on the
/// child's size.
///
/// For example, to align a box at the bottom right, you would pass this box a
/// tight constraint that is bigger than the child's natural size,
/// with an alignment of [FractionalOffset.bottomRight].
///
/// By default, sizes to be as big as possible in both axes. If either axis is
/// unconstrained, then in that direction it will be sized to fit the child's
/// dimensions. Using widthFactor and heightFactor you can force this latter
/// behavior in all cases.
/// This widget will be as big as possible if its dimensions are constrained and
/// [widthFactor] and [heightFactor] are null. If a dimension is unconstrained
/// and the corresponding size factor is null then the widget will match its
/// child's size in that dimension. If a size factor is non-null then the
/// corresponding dimension of this widget will be the product of the child's
/// dimension and the size factor. For example if widthFactor is 0.5 then
/// the width of this widget will always be half of the child's width.
///
/// See also:
///
/// * [CustomSingleChildLayout]
/// * [Center] (which is the same as [Align] but with the [alignment] always
/// set to [FractionalOffset.center])
/// * [FractionallySizedBox] which sizes its child based on its own size.
class
Align
extends
SingleChildRenderObjectWidget
{
/// Creates an alignment widget.
///
...
...
@@ -745,31 +750,34 @@ class ConstrainedBox extends SingleChildRenderObjectWidget {
}
}
/// Sizes itself to a fraction of the total available space.
/// An overflow box that sizes its child to a fraction of the total available space.
/// For more details about the layout algorithm, see [RenderFractionallySizedOverflowBox].
///
/// See [RenderFractionallySizedOverflowBox] for details.
/// See also:
/// * [Align] which can size itself based on its child's size.
/// * [OverflowBox]
class
FractionallySizedBox
extends
SingleChildRenderObjectWidget
{
FractionallySizedBox
({
Key
key
,
this
.
alignment
:
FractionalOffset
.
center
,
this
.
width
,
this
.
height
,
this
.
width
Factor
,
this
.
height
Factor
,
Widget
child
})
:
super
(
key:
key
,
child:
child
)
{
assert
(
alignment
!=
null
&&
alignment
.
dx
!=
null
&&
alignment
.
dy
!=
null
);
}
/// If non-null, the f
actor of the incoming width to use
.
/// If non-null, the f
raction of the incoming width given to the child
.
///
/// If non-null, the child is given a tight width constraint that is the max
/// incoming width constraint multipled by this factor.
final
double
width
;
final
double
width
Factor
;
/// If non-null, the f
actor of the incoming height to use
.
/// If non-null, the f
raction of the incoming height to give to the child
.
///
/// If non-null, the child is given a tight height constraint that is the max
/// incoming height constraint multipled by this factor.
final
double
height
;
final
double
height
Factor
;
/// How to align the child.
///
...
...
@@ -785,26 +793,26 @@ class FractionallySizedBox extends SingleChildRenderObjectWidget {
@override
RenderFractionallySizedOverflowBox
createRenderObject
(
BuildContext
context
)
=>
new
RenderFractionallySizedOverflowBox
(
alignment:
alignment
,
widthFactor:
width
,
heightFactor:
height
widthFactor:
width
Factor
,
heightFactor:
height
Factor
);
@override
void
updateRenderObject
(
BuildContext
context
,
RenderFractionallySizedOverflowBox
renderObject
)
{
renderObject
..
alignment
=
alignment
..
widthFactor
=
width
..
heightFactor
=
height
;
..
widthFactor
=
width
Factor
..
heightFactor
=
height
Factor
;
}
@override
void
debugFillDescription
(
List
<
String
>
description
)
{
super
.
debugFillDescription
(
description
);
description
.
add
(
'alignment:
$alignment
'
);
if
(
width
!=
null
)
description
.
add
(
'width
:
$width
'
);
if
(
height
!=
null
)
description
.
add
(
'height
:
$height
'
);
if
(
width
Factor
!=
null
)
description
.
add
(
'width
Factor:
$widthFactor
'
);
if
(
height
Factor
!=
null
)
description
.
add
(
'height
Factor:
$heightFactor
'
);
}
}
...
...
packages/flutter/test/widget/fractionally_sized_box_test.dart
View file @
502f734d
...
...
@@ -17,8 +17,8 @@ void main() {
alignment:
const
FractionalOffset
(
0.0
,
0.0
),
child:
new
Center
(
child:
new
FractionallySizedBox
(
width:
0.5
,
height:
0.25
,
width
Factor
:
0.5
,
height
Factor
:
0.25
,
child:
new
Container
(
key:
inner
)
...
...
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