首页 > 解决方案 > 如何在容器小部件中添加多行?

问题描述

我想Row在容器小部件中添加一些 s,这是我尝试做的。s 不会出现Row在垂直位置,而是出现在水平位置。

 Container(
  height: 50,
 color:Color(0xFFFFFF),

  child: Row(children: <Widget>[
    Row(children:<Widget>[
  Text('L\'intelligent d\'Abidjan en ligne')]),
  Row(children:<Widget>[Text('le journal en ligne dont vous avez rêvé', style: TextStyle(fontSize: 
  20))]),
  Row(children:<Widget>[RaisedButton(onPressed: (){},
   shape: roundedRectangleBorder,
       child: Text('cliquez pour vous abonner', style: TextStyle(fontSize: 20)),
        color: Color(0xFF1705),
    )]),
     Row(children:<Widget>[Text('le journal en ligne dont vous avez rêvé', style: TextStyle(fontSize: 
   20)) ])

  ]),


  ),

标签: flutter

解决方案


您必须将顶部小部件保留为Column并将您的所有子组件包装Rows为它..

像这样..

Container(
child: Row(
  children: <widget>[
    Row(), //your 1st Row
    Row(), //your 2nd Row
    Row(), //your 3rd Row
  ],
),
)

具体来说,就您而言..我相信,您应该这样做..

Container(
  height: 50,
 color:Color(0xFFFFFF),

  child: Column( //you kept this as Row
    children: <Widget>[
    Row(children:<Widget>[
  Text('L\'intelligent d\'Abidjan en ligne')]),
  Row(children:<Widget>[Text('le journal en ligne dont vous avez rêvé', style: TextStyle(fontSize: 
  20))]),
  Row(children:<Widget>[RaisedButton(onPressed: (){},
   shape: roundedRectangleBorder,
       child: Text('cliquez pour vous abonner', style: TextStyle(fontSize: 20)),
        color: Color(0xFF1705),
    )]),
     Row(children:<Widget>[Text('le journal en ligne dont vous avez rêvé', style: TextStyle(fontSize: 
   20)) ])

  ]),

希望它能回答你的问题..


推荐阅读