Define LayoutWidgetBuilder in terms of BoxConstraints instead of Size (#4578)

This commit is contained in:
Hans Muller
2016-06-15 14:11:58 -07:00
committed by GitHub
parent 661740d2d6
commit 5766cdacd3
4 changed files with 91 additions and 72 deletions

View File

@@ -90,7 +90,8 @@ class _PestoDemoState extends State<PestoDemo> {
)
],
flexibleSpace: new LayoutBuilder(
builder: (BuildContext context, Size size) {
builder: (BuildContext context, BoxConstraints constraints) {
final Size size = constraints.biggest;
double appBarHeight = size.height - statusBarHeight;
double bestHeight = _kLogoImages.keys.lastWhere(
(double height) => appBarHeight >= height
@@ -293,27 +294,33 @@ class _RecipePageState extends State<_RecipePage> {
return new Stack(
children: <Widget>[
_buildContainer(context),
new Padding(
padding: new EdgeInsets.only(top: statusBarHeight),
child: new AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
leading: new IconButton(
icon: Icons.arrow_back,
onPressed: () => Navigator.pop(context),
tooltip: 'Back'
),
actions: <Widget>[
new PopupMenuButton<String>(
onSelected: (String item) {},
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
_buildMenuItem(Icons.share, 'Tweet recipe'),
_buildMenuItem(Icons.email, 'Email recipe'),
_buildMenuItem(Icons.message, 'Message recipe'),
_buildMenuItem(Icons.people, 'Share on Facebook'),
]
)
]
new Positioned(
top: 0.0,
left: 0.0,
right: 0.0,
child: new Container(
height: kToolBarHeight + statusBarHeight,
padding: new EdgeInsets.only(top: statusBarHeight),
child: new AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
leading: new IconButton(
icon: Icons.arrow_back,
onPressed: () => Navigator.pop(context),
tooltip: 'Back'
),
actions: <Widget>[
new PopupMenuButton<String>(
onSelected: (String item) {},
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
_buildMenuItem(Icons.share, 'Tweet recipe'),
_buildMenuItem(Icons.email, 'Email recipe'),
_buildMenuItem(Icons.message, 'Message recipe'),
_buildMenuItem(Icons.people, 'Share on Facebook'),
]
)
]
)
)
)
]