Tim*_*Sim 2 flutter flutter-layout
我有一个应用栏,我想在其中显示标题,然后在它旁边有一个凸起的按钮,可以扩展以填充剩余的水平空间。我尝试了以下变体:
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
},
),),
])),
]
),
);
Run Code Online (Sandbox Code Playgroud)
为此,我收到以下错误:
I/flutter (26477):在 performLayout() 期间抛出以下断言:
I/flutter (26477):_ToolbarLayout 自定义多子布局委托忘记布置以下子项:
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):每个子项必须只布置一次。
我尝试过的所有其他事情也抛出了一些断言异常。我真的不在乎我是怎么做的,我只想有两个小部件 - 标题和旁边的一个RaisedButton填充应用程序栏中其余空间的小部件。
只需删除包含 RaisedButton
appBar: AppBar(
title: Row(children: [
Text("Select view"),
Expanded(
child: RaisedButton(
child: Text("view 1"),
onPressed: () {
// something
},
),
),
]),
),
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2869 次 |
| 最近记录: |