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
ebe6da5b
Commit
ebe6da5b
authored
Apr 08, 2017
by
Ian Hickson
Committed by
GitHub
Apr 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename BlockBody to ListBody. (#9291)
Nobody knew what a Block was.
parent
f9ae2267
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
79 additions
and
66 deletions
+79
-66
main.dart
dev/benchmarks/complex_layout/lib/main.dart
+2
-2
about.dart
packages/flutter/lib/src/material/about.dart
+2
-2
dialog.dart
packages/flutter/lib/src/material/dialog.dart
+1
-1
expansion_panel.dart
packages/flutter/lib/src/material/expansion_panel.dart
+1
-1
mergeable_material.dart
packages/flutter/lib/src/material/mergeable_material.dart
+14
-14
popup_menu.dart
packages/flutter/lib/src/material/popup_menu.dart
+1
-1
block.dart
packages/flutter/lib/src/rendering/block.dart
+33
-31
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+19
-8
single_child_scroll_view.dart
...ges/flutter/lib/src/widgets/single_child_scroll_view.dart
+2
-2
paragraph_intrinsics_test.dart
...ges/flutter/test/rendering/paragraph_intrinsics_test.dart
+2
-2
ensure_visible_test.dart
packages/flutter/test/widgets/ensure_visible_test.dart
+2
-2
No files found.
dev/benchmarks/complex_layout/lib/main.dart
View file @
ebe6da5b
...
...
@@ -170,7 +170,7 @@ class FancyImageItem extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
return
new
Block
Body
(
return
new
List
Body
(
children:
<
Widget
>[
new
UserHeader
(
'Ali Connors
$index
'
),
new
ItemDescription
(),
...
...
@@ -193,7 +193,7 @@ class FancyGalleryItem extends StatelessWidget {
final
int
index
;
@override
Widget
build
(
BuildContext
context
)
{
return
new
Block
Body
(
return
new
List
Body
(
children:
<
Widget
>[
new
UserHeader
(
'Ali Connors'
),
new
ItemGalleryBox
(
index
),
...
...
packages/flutter/lib/src/material/about.dart
View file @
ebe6da5b
...
...
@@ -266,7 +266,7 @@ class AboutDialog extends StatelessWidget {
body
.
add
(
new
Expanded
(
child:
new
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
24.0
),
child:
new
Block
Body
(
child:
new
List
Body
(
children:
<
Widget
>[
new
Text
(
name
,
style:
Theme
.
of
(
context
).
textTheme
.
headline
),
new
Text
(
version
,
style:
Theme
.
of
(
context
).
textTheme
.
body1
),
...
...
@@ -286,7 +286,7 @@ class AboutDialog extends StatelessWidget {
body
.
addAll
(
children
);
return
new
AlertDialog
(
content:
new
SingleChildScrollView
(
child:
new
Block
Body
(
children:
body
),
child:
new
List
Body
(
children:
body
),
),
actions:
<
Widget
>[
new
FlatButton
(
...
...
packages/flutter/lib/src/material/dialog.dart
View file @
ebe6da5b
...
...
@@ -293,7 +293,7 @@ class SimpleDialog extends StatelessWidget {
body
.
add
(
new
Flexible
(
child:
new
SingleChildScrollView
(
padding:
contentPadding
??
const
EdgeInsets
.
fromLTRB
(
0.0
,
12.0
,
0.0
,
16.0
),
child:
new
Block
Body
(
children:
children
),
child:
new
List
Body
(
children:
children
),
)
));
}
...
...
packages/flutter/lib/src/material/expansion_panel.dart
View file @
ebe6da5b
...
...
@@ -84,7 +84,7 @@ class ExpansionPanelList extends StatelessWidget {
}
/// The children of the expansion panel list. They are layed in a similar
/// fashion to [
Block
Body].
/// fashion to [
List
Body].
final
List
<
ExpansionPanel
>
children
;
/// The callback that gets called whenever one of the expand/collapse buttons
...
...
packages/flutter/lib/src/material/mergeable_material.dart
View file @
ebe6da5b
...
...
@@ -74,7 +74,7 @@ class MaterialGap extends MergeableMaterialItem {
/// Displays a list of [MergeableMaterialItem] children. The list contains
/// [MaterialSlice] items whose boundaries are either "merged" with adjacent
/// items or separated by a [MaterialGap]. The [children] are distributed along
/// the given [mainAxis] in the same way as the children of a [
Block
Body]. When
/// the given [mainAxis] in the same way as the children of a [
List
Body]. When
/// the list of children changes, gaps are automatically animated open or closed
/// as needed.
///
...
...
@@ -522,7 +522,7 @@ class _MergeableMaterialState extends State<MergeableMaterial> with TickerProvid
borderRadius:
_borderRadius
(
i
-
1
,
widgets
.
isEmpty
,
false
),
shape:
BoxShape
.
rectangle
),
child:
new
Block
Body
(
child:
new
List
Body
(
mainAxis:
config
.
mainAxis
,
children:
slices
)
...
...
@@ -593,7 +593,7 @@ class _MergeableMaterialState extends State<MergeableMaterial> with TickerProvid
borderRadius:
_borderRadius
(
i
-
1
,
widgets
.
isEmpty
,
true
),
shape:
BoxShape
.
rectangle
),
child:
new
Block
Body
(
child:
new
List
Body
(
mainAxis:
config
.
mainAxis
,
children:
slices
)
...
...
@@ -602,7 +602,7 @@ class _MergeableMaterialState extends State<MergeableMaterial> with TickerProvid
slices
=
<
Widget
>[];
}
return
new
_MergeableMaterial
Block
Body
(
return
new
_MergeableMaterial
List
Body
(
mainAxis:
config
.
mainAxis
,
boxShadows:
kElevationToShadow
[
config
.
elevation
],
items:
_children
,
...
...
@@ -635,8 +635,8 @@ class _MergeableMaterialSliceKey extends GlobalKey {
}
}
class
_MergeableMaterial
BlockBody
extends
Block
Body
{
_MergeableMaterial
Block
Body
({
class
_MergeableMaterial
ListBody
extends
List
Body
{
_MergeableMaterial
List
Body
({
List
<
Widget
>
children
,
Axis
mainAxis:
Axis
.
vertical
,
this
.
items
,
...
...
@@ -647,24 +647,24 @@ class _MergeableMaterialBlockBody extends BlockBody {
List
<
BoxShadow
>
boxShadows
;
@override
Render
Block
createRenderObject
(
BuildContext
context
)
{
return
new
_
MergeableMaterialRenderBlock
(
Render
ListBody
createRenderObject
(
BuildContext
context
)
{
return
new
_
RenderMergeableMaterialListBody
(
mainAxis:
mainAxis
,
boxShadows:
boxShadows
);
}
@override
void
updateRenderObject
(
BuildContext
context
,
Render
Block
renderObject
)
{
final
_
MergeableMaterialRenderBlock
materialRenderBlock
=
renderObject
;
materialRender
Block
void
updateRenderObject
(
BuildContext
context
,
Render
ListBody
renderObject
)
{
final
_
RenderMergeableMaterialListBody
materialRenderListBody
=
renderObject
;
materialRender
ListBody
..
mainAxis
=
mainAxis
..
boxShadows
=
boxShadows
;
}
}
class
_
MergeableMaterialRenderBlock
extends
RenderBlock
{
_
MergeableMaterialRenderBlock
({
class
_
RenderMergeableMaterialListBody
extends
RenderListBody
{
_
RenderMergeableMaterialListBody
({
List
<
RenderBox
>
children
,
Axis
mainAxis:
Axis
.
vertical
,
this
.
boxShadows
...
...
@@ -692,7 +692,7 @@ class _MergeableMaterialRenderBlock extends RenderBlock {
int
i
=
0
;
while
(
child
!=
null
)
{
final
Block
ParentData
childParentData
=
child
.
parentData
;
final
ListBody
ParentData
childParentData
=
child
.
parentData
;
final
Rect
rect
=
(
childParentData
.
offset
+
offset
)
&
child
.
size
;
if
(
i
%
2
==
0
)
_paintShadows
(
context
.
canvas
,
rect
);
...
...
packages/flutter/lib/src/material/popup_menu.dart
View file @
ebe6da5b
...
...
@@ -300,7 +300,7 @@ class _PopupMenu<T> extends StatelessWidget {
padding:
const
EdgeInsets
.
symmetric
(
vertical:
_kMenuVerticalPadding
),
child:
new
Block
Body
(
children:
children
),
child:
new
List
Body
(
children:
children
),
)
)
);
...
...
packages/flutter/lib/src/rendering/block.dart
View file @
ebe6da5b
...
...
@@ -7,37 +7,39 @@ import 'dart:math' as math;
import
'box.dart'
;
import
'object.dart'
;
/// Parent data for use with [Render
BlockBase
].
class
Block
ParentData
extends
ContainerBoxParentDataMixin
<
RenderBox
>
{
}
/// Parent data for use with [Render
ListBody
].
class
ListBody
ParentData
extends
ContainerBoxParentDataMixin
<
RenderBox
>
{
}
typedef
double
_ChildSizingFunction
(
RenderBox
child
);
/// Implements the block layout algorithm.
/// Displays its children sequentially along a given axis, forcing them to the
/// dimensions of the parent in the other axis.
///
/// In block layout, children are arranged linearly along the main axis (either
/// horizontally or vertically). In the cross axis, children are stretched to
/// match the block's cross-axis extent. In the main axis, children are given
/// unlimited space and the block expands its main axis to contain all its
/// children. Because blocks expand in the main axis, blocks must be given
/// unlimited space in the main axis, typically by being contained in a
/// viewport with a scrolling direction that matches the block's main axis.
class
RenderBlock
extends
RenderBox
with
ContainerRenderObjectMixin
<
RenderBox
,
BlockParentData
>,
RenderBoxContainerDefaultsMixin
<
RenderBox
,
BlockParentData
>
{
/// Creates a block render object.
/// This layout algorithm arranges its children linearly along the main axis
/// (either horizontally or vertically). In the cross axis, children are
/// stretched to match the box's cross-axis extent. In the main axis, children
/// are given unlimited space and the box expands its main axis to contain all
/// its children. Because [RenderListBody] boxes expand in the main axis, they
/// must be given unlimited space in the main axis, typically by being contained
/// in a viewport with a scrolling direction that matches the box's main axis.
class
RenderListBody
extends
RenderBox
with
ContainerRenderObjectMixin
<
RenderBox
,
ListBodyParentData
>,
RenderBoxContainerDefaultsMixin
<
RenderBox
,
ListBodyParentData
>
{
/// Creates a render object that arranges its children sequentially along a
/// given axis.
///
/// By default,
the block positions children
along the vertical axis.
Render
Block
({
/// By default,
children are arranged
along the vertical axis.
Render
ListBody
({
List
<
RenderBox
>
children
,
Axis
mainAxis:
Axis
.
vertical
Axis
mainAxis:
Axis
.
vertical
,
})
:
_mainAxis
=
mainAxis
{
addAll
(
children
);
}
@override
void
setupParentData
(
RenderBox
child
)
{
if
(
child
.
parentData
is
!
Block
ParentData
)
child
.
parentData
=
new
Block
ParentData
();
if
(
child
.
parentData
is
!
ListBody
ParentData
)
child
.
parentData
=
new
ListBody
ParentData
();
}
/// The direction to use as the main axis.
...
...
@@ -90,10 +92,10 @@ class RenderBlock extends RenderBox
break
;
}
throw
new
FlutterError
(
'Render
Block
must have unlimited space along its main axis.
\n
'
'Render
Block
does not clip or resize its children, so it must be '
'placed in a parent that does not constrain the
block
\'
s
main '
'axis. You probably want to put the Render
Block
inside a '
'Render
ListBody
must have unlimited space along its main axis.
\n
'
'Render
ListBody
does not clip or resize its children, so it must be '
'placed in a parent that does not constrain the main '
'axis. You probably want to put the Render
ListBody
inside a '
'RenderViewport with a matching main axis.'
);
});
...
...
@@ -112,11 +114,11 @@ class RenderBlock extends RenderBox
// more specific to the exact situation in that case, and don't mention
// nesting blocks in the negative case.
throw
new
FlutterError
(
'Render
Block
must have a bounded constraint for its cross axis.
\n
'
'Render
Block forces its children to expand to fit the block
\'
s container, '
'so it must be placed in a parent that
does constrain the block
\'
s
cross '
'axis to a finite dimension. If you are attempting to nest a
block
with '
'one direction inside
a block
of another direction, you will want to '
'Render
ListBody
must have a bounded constraint for its cross axis.
\n
'
'Render
ListBody forces its children to expand to fit the RenderListBody
\'
s container, '
'so it must be placed in a parent that
constrains the
cross '
'axis to a finite dimension. If you are attempting to nest a
RenderListBody
with '
'one direction inside
one
of another direction, you will want to '
'wrap the inner one inside a box that fixes the dimension in that direction, '
'for example, a RenderIntrinsicWidth or RenderIntrinsicHeight object. '
'This is relatively expensive, however.'
// (that's why we don't do it automatically)
...
...
@@ -127,7 +129,7 @@ class RenderBlock extends RenderBox
RenderBox
child
=
firstChild
;
while
(
child
!=
null
)
{
child
.
layout
(
innerConstraints
,
parentUsesSize:
true
);
final
Block
ParentData
childParentData
=
child
.
parentData
;
final
ListBody
ParentData
childParentData
=
child
.
parentData
;
switch
(
mainAxis
)
{
case
Axis
.
horizontal
:
childParentData
.
offset
=
new
Offset
(
position
,
0.0
);
...
...
@@ -164,7 +166,7 @@ class RenderBlock extends RenderBox
RenderBox
child
=
firstChild
;
while
(
child
!=
null
)
{
extent
=
math
.
max
(
extent
,
childSize
(
child
));
final
Block
ParentData
childParentData
=
child
.
parentData
;
final
ListBody
ParentData
childParentData
=
child
.
parentData
;
child
=
childParentData
.
nextSibling
;
}
return
extent
;
...
...
@@ -175,7 +177,7 @@ class RenderBlock extends RenderBox
RenderBox
child
=
firstChild
;
while
(
child
!=
null
)
{
extent
+=
childSize
(
child
);
final
Block
ParentData
childParentData
=
child
.
parentData
;
final
ListBody
ParentData
childParentData
=
child
.
parentData
;
child
=
childParentData
.
nextSibling
;
}
return
extent
;
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
ebe6da5b
...
...
@@ -1539,19 +1539,30 @@ class SliverPadding extends SingleChildRenderObjectWidget {
// LAYOUT NODES
/// A widget that uses the block layout algorithm for its children.
/// A widget that arranges its children sequentially along a given axis, forcing
/// them to the dimension of the parent in the other axis.
///
/// This widget is rarely used directly. Instead, consider using [
SliverList
],
/// This widget is rarely used directly. Instead, consider using [
ListView
],
/// which combines a similar layout algorithm with scrolling behavior, or
/// [Column], which gives you more flexible control over the layout of a
/// vertical set of boxes.
///
/// For details about the block layout algorithm, see [RenderBlockBase].
class
BlockBody
extends
MultiChildRenderObjectWidget
{
/// Creates a block layout widget.
/// See also:
///
/// * [RenderListBody], which implements this layout algorithm and the
/// documentation for which describes some of its subtleties.
/// * [SingleChildScrollView], which is sometimes used with [ListBody] to
/// make the contents scrollable.
/// * [Column] and [Row], which implement a more elaborate version of
/// this layout algorithm (at the cost of being slightly less efficient).
/// * [ListView], which implements an efficient scrolling version of this
/// layout algorithm.
class
ListBody
extends
MultiChildRenderObjectWidget
{
/// Creates a layout widget that arranges its children sequentially along a
/// given axis.
///
/// By default, the [mainAxis] is [Axis.vertical].
Block
Body
({
List
Body
({
Key
key
,
this
.
mainAxis
:
Axis
.
vertical
,
List
<
Widget
>
children:
const
<
Widget
>[],
...
...
@@ -1562,10 +1573,10 @@ class BlockBody extends MultiChildRenderObjectWidget {
final
Axis
mainAxis
;
@override
Render
Block
createRenderObject
(
BuildContext
context
)
=>
new
RenderBlock
(
mainAxis:
mainAxis
);
Render
ListBody
createRenderObject
(
BuildContext
context
)
=>
new
RenderListBody
(
mainAxis:
mainAxis
);
@override
void
updateRenderObject
(
BuildContext
context
,
Render
Block
renderObject
)
{
void
updateRenderObject
(
BuildContext
context
,
Render
ListBody
renderObject
)
{
renderObject
.
mainAxis
=
mainAxis
;
}
}
...
...
packages/flutter/lib/src/widgets/single_child_scroll_view.dart
View file @
ebe6da5b
...
...
@@ -23,12 +23,12 @@ import 'scrollable.dart';
/// It is also useful if you need to shrink-wrap in both axes (the main
/// scrolling direction as well as the cross axis), as one might see in a dialog
/// or pop-up menu. In that case, you might pair the [SingleChildScrollView]
/// with a [
Block
Body] child.
/// with a [
List
Body] child.
///
/// When you have a list of children and do not require cross-axis
/// shrink-wrapping behavior, for example a scrolling list that is always the
/// width of the screen, consider [ListView], which is vastly more efficient
/// that a [SingleChildScrollView] containing a [
Block
Body] or [Column] with
/// that a [SingleChildScrollView] containing a [
List
Body] or [Column] with
/// many children.
///
/// See also:
...
...
packages/flutter/test/rendering/paragraph_intrinsics_test.dart
View file @
ebe6da5b
...
...
@@ -6,14 +6,14 @@ import 'package:flutter/rendering.dart';
import
'package:test/test.dart'
;
void
main
(
)
{
test
(
'
block
and paragraph intrinsics'
,
()
{
test
(
'
list body
and paragraph intrinsics'
,
()
{
final
RenderParagraph
paragraph
=
new
RenderParagraph
(
const
TextSpan
(
style:
const
TextStyle
(
height:
1.0
),
text:
'Hello World'
)
);
final
Render
Block
testBlock
=
new
RenderBlock
(
final
Render
ListBody
testBlock
=
new
RenderListBody
(
children:
<
RenderBox
>[
paragraph
,
]
...
...
packages/flutter/test/widgets/ensure_visible_test.dart
View file @
ebe6da5b
...
...
@@ -18,7 +18,7 @@ Widget buildSingleChildScrollView(Axis scrollDirection, { bool reverse: false })
child:
new
SingleChildScrollView
(
scrollDirection:
scrollDirection
,
reverse:
reverse
,
child:
new
Block
Body
(
child:
new
List
Body
(
mainAxis:
scrollDirection
,
children:
<
Widget
>[
new
Container
(
key:
const
ValueKey
<
int
>(
0
),
width:
200.0
,
height:
200.0
),
...
...
@@ -178,7 +178,7 @@ void main() {
width:
600.0
,
height:
400.0
,
child:
new
SingleChildScrollView
(
child:
new
Block
Body
(
child:
new
List
Body
(
children:
<
Widget
>[
new
Container
(
height:
200.0
),
new
Container
(
height:
200.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