AppBar 中的扩展小部件
Expanded widget in AppBar
我有一个应用栏,我想在其中显示标题,然后在它旁边有一个凸起的按钮,该按钮会展开以填充剩余的水平区域 space。我试过这个的变体:
AppBar(
title: Row(
children: [
Text("Select view"),
// the row that follows is because it says Expanded widgets
// should be put directly in Row or Column or Flex
Padding(padding: EdgeInsets.only(left: 12.0), child: Row(children: [
Expanded(child: RaisedButton(
child: Text("view 1"),
onPressed: () {
// something
},
),),
])),
]
),
);
为此,我收到以下错误:
I/flutter (26477): The following assertion was thrown during performLayout():
I/flutter (26477): The _ToolbarLayout custom multichild layout delegate forgot to lay out the following children:
I/flutter (26477): _ToolbarSlot.middle: RenderSemanticsAnnotations#6d937 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (26477): _ToolbarSlot.middle: RenderSemanticsAnnotations#7fcd5 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (26477): _ToolbarSlot.middle: RenderSemanticsAnnotations#f9a7a NEEDS-LAYOUT NEEDS-PAINT
I/flutter (26477): _ToolbarSlot.middle: RenderSemanticsAnnotations#ce1f2 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (26477): Each child must be laid out exactly once.
我尝试的所有其他事情也抛出了一些断言异常。我真的不在乎我是怎么做的,我只想有两个小部件 - 标题和旁边的 RaisedButton
填充应用栏中 space 的其余部分。
只需删除包含 RaisedButton
的行
appBar: AppBar(
title: Row(children: [
Text("Select view"),
Expanded(
child: RaisedButton(
child: Text("view 1"),
onPressed: () {
// something
},
),
),
]),
),
我有一个应用栏,我想在其中显示标题,然后在它旁边有一个凸起的按钮,该按钮会展开以填充剩余的水平区域 space。我试过这个的变体:
AppBar(
title: Row(
children: [
Text("Select view"),
// the row that follows is because it says Expanded widgets
// should be put directly in Row or Column or Flex
Padding(padding: EdgeInsets.only(left: 12.0), child: Row(children: [
Expanded(child: RaisedButton(
child: Text("view 1"),
onPressed: () {
// something
},
),),
])),
]
),
);
为此,我收到以下错误:
I/flutter (26477): The following assertion was thrown during performLayout():
I/flutter (26477): The _ToolbarLayout custom multichild layout delegate forgot to lay out the following children:
I/flutter (26477): _ToolbarSlot.middle: RenderSemanticsAnnotations#6d937 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (26477): _ToolbarSlot.middle: RenderSemanticsAnnotations#7fcd5 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (26477): _ToolbarSlot.middle: RenderSemanticsAnnotations#f9a7a NEEDS-LAYOUT NEEDS-PAINT
I/flutter (26477): _ToolbarSlot.middle: RenderSemanticsAnnotations#ce1f2 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (26477): Each child must be laid out exactly once.
我尝试的所有其他事情也抛出了一些断言异常。我真的不在乎我是怎么做的,我只想有两个小部件 - 标题和旁边的 RaisedButton
填充应用栏中 space 的其余部分。
只需删除包含 RaisedButton
appBar: AppBar(
title: Row(children: [
Text("Select view"),
Expanded(
child: RaisedButton(
child: Text("view 1"),
onPressed: () {
// something
},
),
),
]),
),