Flutter:组件Flutter

Flutter 布局之:row设置左右两端各有控件

2020-04-24  本文已影响0人  程序狮
Row(
  children: <Widget>[
    Text('我是左边的', style: TextStyle(fontSize: 15, color: Color(Config.COLOR_E1BB7D))),
    Expanded(
      child: Text(''), // 中间用Expanded控件
    ),
    Text('我是右边的', style: TextStyle(fontSize: 12, color: Color(Config.COLOR_E1BB7D))),
  ],
)

如果Row中嵌套Row,里面的Row用Expanded则会报错

The nearest ancestor providing an unbounded width constraint is: RenderFlex#3fe19 relayoutBoundary=up7 NEEDS-LAYOUT NEEDS-PAINT

在底层Row()组件中直接利用撑开组件Expanded,而上一层父组件或某个N父组件大小是特别灵活没有定大小是弹性的。
所以整体在flutter中无法计算大小来撑开布局,这时候就把\color{red}{父组件上面的Row内也使用了Expanded组件撑开}才得以不报错

上一篇 下一篇

猜你喜欢

热点阅读