Flutter 如何在两个文本fname和contact之间创建空间?

Flutter 如何在两个文本fname和contact之间创建空间?,flutter,dart,google-cloud-firestore,Flutter,Dart,Google Cloud Firestore,我想在“fname”和“contact”之间创建空间。它以以下格式显示:-1:Mayank,2:77177 但我想以这种格式显示文本:- 1:Mayank 2:77177 Widget buildResultCard(data) { return Scaffold( body: Container( child: Card( color: Colors.white, shape: RoundedRectangleBord

我想在“fname”和“contact”之间创建空间。它以以下格式显示:-1:Mayank,2:77177

但我想以这种格式显示文本:-

1:Mayank

2:77177

Widget buildResultCard(data) {
    return Scaffold(
      body: Container(
        child: Card(
          color: Colors.white,
          shape: RoundedRectangleBorder(
            side: BorderSide(color: Colors.purpleAccent,width: 2),
            borderRadius: BorderRadius.circular(10),
          ),
          child: Padding(
            padding: const EdgeInsets.all(16.0),
            child: Row(
              children: <Widget>[
                Container(
              width:150,
              height: 200,
                  padding: const EdgeInsets.only(top: 2.0, bottom: 5.0),
                  child: Row(children: <Widget>[
                    Image.network(data['image'],width: 150, height: 150,fit: BoxFit.cover,),
                    Spacer(),
                  ]),
                ),
                SizedBox(width: 10),
              Text(data['fname'], style: new TextStyle(fontSize: 15.0,),),

           // Want to display one next the other.

                Text(data['contact'], style: new TextStyle(fontSize: 15.0,height: 1.5),),
              ],
            ),
          ),
        ),
      ),
    );
  }
Widget buildResultCard(数据){
返回脚手架(
主体:容器(
孩子:卡片(
颜色:颜色,白色,
形状:圆形矩形边框(
侧边:边框侧边(颜色:颜色。紫色,宽度:2),
边界半径:边界半径。圆形(10),
),
孩子:填充(
填充:常数边集全部(16.0),
孩子:排(
儿童:[
容器(
宽度:150,
身高:200,
填充:仅限常量边集(顶部:2.0,底部:5.0),
子对象:行(子对象:[
网络(数据['Image'],宽度:150,高度:150,尺寸:BoxFit.cover,),
垫片(),
]),
),
尺寸箱(宽度:10),
文本(数据['fname',样式:新文本样式(fontSize:15.0,),),
//想要一个接一个地显示。
文本(数据['contact',样式:新文本样式(字体大小:15.0,高度:1.5),),
],
),
),
),
),
);
}

您可以使用以下两个选项之一:

  • 将文本包装在列小部件中
  • \n添加一个“行尾”
  • 示例(2):

    新文本(':-\n\n${data['fname']},\n\n${data['contact']})

    这可能会奏效:

    return Scaffold(
          body: Container(
            child: Card(
              color: Colors.white,
              shape: RoundedRectangleBorder(
                side: BorderSide(color: Colors.purpleAccent,width: 2),
                borderRadius: BorderRadius.circular(10),
              ),
              child: Padding(
                padding: const EdgeInsets.all(16.0),
                child: Row(
                  children: <Widget>[
                    Container(
                      width:150,
                      height: 200,
                      padding: const EdgeInsets.only(top: 2.0, bottom: 5.0),
                      child: Row(children: <Widget>[
                        Image.network(data['image'],width: 150, height: 150,fit: BoxFit.cover,),
                        Spacer(),
                      ]),
                    ),
                    SizedBox(width: 10),
                    Column(mainAxisSize: MainAxisSize.min,
                      children: <Widget>[
                      Text(data['fname'], style: new TextStyle(fontSize: 15.0,),),
    
                      // Want to display one next the other.
    
                      Text(data['contact'], style: new TextStyle(fontSize: 15.0,height: 1.5),),
                     ],
                    ),
    
                  ],
                ),
              ),
            ),
          ),
        );
    
    返回脚手架(
    主体:容器(
    孩子:卡片(
    颜色:颜色,白色,
    形状:圆形矩形边框(
    侧边:边框侧边(颜色:颜色。紫色,宽度:2),
    边界半径:边界半径。圆形(10),
    ),
    孩子:填充(
    填充:常数边集全部(16.0),
    孩子:排(
    儿童:[
    容器(
    宽度:150,
    身高:200,
    填充:仅限常量边集(顶部:2.0,底部:5.0),
    子对象:行(子对象:[
    网络(数据['Image'],宽度:150,高度:150,尺寸:BoxFit.cover,),
    垫片(),
    ]),
    ),
    尺寸箱(宽度:10),
    列(mainAxisSize:mainAxisSize.min,
    儿童:[
    文本(数据['fname',样式:新文本样式(fontSize:15.0,),),
    //想要一个接一个地显示。
    文本(数据['contact',样式:新文本样式(字体大小:15.0,高度:1.5),),
    ],
    ),
    ],
    ),
    ),
    ),
    ),
    );
    

    我试图将修改保持在较低的水平,以便对您有用。我所做的只是在文本框中添加一列。