简体   繁体   English

如何使用 flutter 在对话框或警报对话框中创建行

[英]How to create Row in dialog or alert dialog using flutter

I am trying to create a row in a dialog or alert dialog box so I can add a form for first and last name in flutter.我正在尝试在对话框或警报对话框中创建一行,以便可以在 flutter 中添加名字和姓氏的表格。 这是一行小部件中名字和姓氏的图像

I didn't test it but this should work,all you have to do is style the widgets in the Row widget according to the image you put我没有对其进行测试,但这应该可以,您所要做的就是根据您放置的图像设置 Row 小部件中的小部件样式

 showAlertDialog(BuildContext context) {
    AlertDialog alert = AlertDialog(
 
      content: Container(
          child: Row(
             children:[
                 Expanded(
                    child: TextField(
                          decoration: InputDecoration(
                    hintText: "First Name",
                        ),
                     ),
                  ),
                 Expanded(
                    child: TextField(
                          decoration: InputDecoration(
                    hintText: "Last Name",
                       ),
                     ),
                  ),
             ]
          ),
       ),
    );

    // show the dialog
    showDialog(
      context: context,
      builder: (BuildContext context) {
        return alert;
      },
    );
  }

For a column to form in an alert dialog box you have put the textfield in an expanded widget.对于要在警报对话框中形成的列,您已将文本字段放在展开的小部件中。

 Row(children: [
                Expanded(
                    child: TextField(),
                ),
               SizedBox(width: 8.0,),
               Expanded(
                   child: TextField(),
               ),
    ]),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM