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
e7d5c7d6
Commit
e7d5c7d6
authored
Nov 03, 2016
by
Ian Hickson
Committed by
GitHub
Nov 03, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change 'body' to be loosely constrained. (#6692)
People get confused by the tight constraints.
parent
20063c5e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
12 deletions
+51
-12
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+13
-12
scaffold_test.dart
packages/flutter/test/material/scaffold_test.dart
+38
-0
No files found.
packages/flutter/lib/src/material/scaffold.dart
View file @
e7d5c7d6
...
...
@@ -79,7 +79,7 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate {
// This part of the layout has the same effect as putting the app bar and
// body in a column and making the body flexible. What's different is that
// in this case the app bar appears
-after-
the body in the stacking order,
// in this case the app bar appears
_after_
the body in the stacking order,
// so the app bar's shadow is drawn on top of the body.
final
BoxConstraints
fullWidthConstraints
=
looseConstraints
.
tighten
(
width:
size
.
width
);
...
...
@@ -108,7 +108,10 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate {
if
(
hasChild
(
_ScaffoldSlot
.
body
))
{
final
double
bodyHeight
=
contentBottom
-
contentTop
;
final
BoxConstraints
bodyConstraints
=
fullWidthConstraints
.
tighten
(
height:
bodyHeight
);
final
BoxConstraints
bodyConstraints
=
new
BoxConstraints
(
maxWidth:
fullWidthConstraints
.
maxWidth
,
maxHeight:
bodyHeight
,
);
layoutChild
(
_ScaffoldSlot
.
body
,
bodyConstraints
);
positionChild
(
_ScaffoldSlot
.
body
,
new
Offset
(
0.0
,
contentTop
));
}
...
...
@@ -325,22 +328,20 @@ class Scaffold extends StatefulWidget {
/// [drawer]. To avoid the body being resized to avoid the window padding
/// (e.g., from the onscreen keyboard), see [resizeToAvoidBottomPadding].
///
/// The widget in the body of the scaffold will be forced to the size of the
/// available space, to cover the entire scaffold other than any app bars,
/// footer buttons, or navigation bars.
///
/// To center this widget instead, consider putting it in a [Center] widget
/// and having that be the body.
/// The widget in the body of the scaffold is positioned at the top-left of
/// the available space between the app bar and the bottom of the scaffold. To
/// center this widget instead, consider putting it in a [Center] widget and
/// having that be the body.
///
/// If you have a column of widgets that should normally fit on the screen,
/// but may overflow and would in such cases need to scroll, consider using a
/// [Block] as the body of the scaffold.
///
/// If you have a list of items, consider using a [LazyBlock]
or
/// [LazyScrollableList] as the body of the scaffold.
/// If you have a list of items, consider using a [LazyBlock]
,
/// [LazyScrollableList]
, or [MaterialList]
as the body of the scaffold.
final
Widget
body
;
/// A button displayed on top of the
body
.
/// A button displayed on top of the
[body]
.
///
/// Typically a [FloatingActionButton].
final
Widget
floatingActionButton
;
...
...
@@ -357,7 +358,7 @@ class Scaffold extends StatefulWidget {
/// * <https://material.google.com/components/buttons.html#buttons-persistent-footer-buttons>
final
List
<
Widget
>
persistentFooterButtons
;
/// A panel displayed to the side of the
body
, often hidden on mobile devices.
/// A panel displayed to the side of the
[body]
, often hidden on mobile devices.
///
/// Typically a [Drawer].
final
Widget
drawer
;
...
...
packages/flutter/test/material/scaffold_test.dart
View file @
e7d5c7d6
...
...
@@ -305,4 +305,42 @@ void main() {
await
expectBackIcon
(
tester
,
TargetPlatform
.
iOS
,
Icons
.
arrow_back_ios
);
});
});
group
(
'body size'
,
()
{
testWidgets
(
'body size with container'
,
(
WidgetTester
tester
)
async
{
Key
testKey
=
new
UniqueKey
();
await
tester
.
pumpWidget
(
new
Scaffold
(
body:
new
Container
(
key:
testKey
))
);
expect
(
tester
.
element
(
find
.
byKey
(
testKey
)).
size
,
const
Size
(
800.0
,
600.0
));
expect
(
tester
.
renderObject
/*<RenderBox>*/
(
find
.
byKey
(
testKey
)).
localToGlobal
(
Point
.
origin
),
const
Point
(
0.0
,
0.0
));
});
testWidgets
(
'body size with sized container'
,
(
WidgetTester
tester
)
async
{
Key
testKey
=
new
UniqueKey
();
await
tester
.
pumpWidget
(
new
Scaffold
(
body:
new
Container
(
key:
testKey
,
height:
100.0
))
);
expect
(
tester
.
element
(
find
.
byKey
(
testKey
)).
size
,
const
Size
(
800.0
,
100.0
));
expect
(
tester
.
renderObject
/*<RenderBox>*/
(
find
.
byKey
(
testKey
)).
localToGlobal
(
Point
.
origin
),
const
Point
(
0.0
,
0.0
));
});
testWidgets
(
'body size with centered container'
,
(
WidgetTester
tester
)
async
{
Key
testKey
=
new
UniqueKey
();
await
tester
.
pumpWidget
(
new
Scaffold
(
body:
new
Center
(
child:
new
Container
(
key:
testKey
)))
);
expect
(
tester
.
element
(
find
.
byKey
(
testKey
)).
size
,
const
Size
(
800.0
,
600.0
));
expect
(
tester
.
renderObject
/*<RenderBox>*/
(
find
.
byKey
(
testKey
)).
localToGlobal
(
Point
.
origin
),
const
Point
(
0.0
,
0.0
));
});
testWidgets
(
'body size with button'
,
(
WidgetTester
tester
)
async
{
Key
testKey
=
new
UniqueKey
();
await
tester
.
pumpWidget
(
new
Scaffold
(
body:
new
FlatButton
(
key:
testKey
,
onPressed:
()
{
},
child:
new
Text
(
''
)))
);
expect
(
tester
.
element
(
find
.
byKey
(
testKey
)).
size
,
const
Size
(
88.0
,
36.0
));
expect
(
tester
.
renderObject
/*<RenderBox>*/
(
find
.
byKey
(
testKey
)).
localToGlobal
(
Point
.
origin
),
const
Point
(
0.0
,
0.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