Flutter 如何在同一行中定位两个小部件?

Flutter 如何在同一行中定位两个小部件?,flutter,Flutter,我有一个国家代码(下拉菜单)和电话(TextFormField),我怎么能把它们放在同一个级别? 我试过对齐小部件 Row( children: <Widget>[ Flexible( flex: 1, child: DropdownButtonFormField( value: _select

我有一个国家代码(下拉菜单)和电话(TextFormField),我怎么能把它们放在同一个级别? 我试过对齐小部件

Row(
                children: <Widget>[
                  Flexible(
                    flex: 1,
                    child: DropdownButtonFormField(
                      value: _selectedCountryCode ?? 'TR',
                      onChanged: (value) {
                        setState(() {
                          _selectedCountryCode = value;
                        });
                      },
                      items: countryCodes,
                    ),
                  ),
                  Flexible(
                    flex: 4,
                    child: Padding(
                      padding: const EdgeInsets.all(16.0),
                      child: TextFormField(
                        decoration: InputDecoration(labelText: "Phone"),
                      ),
                    ),
                  ),
                ],
              ),
行(
儿童:[
灵活的(
弹性:1,
子项:DropdownButtonFormField(
值:\ u selectedCountryCode???'TR',
一旦更改:(值){
设置状态(){
_selectedCountryCode=值;
});
},
项目:国家代码,
),
),
灵活的(
弹性:4,
孩子:填充(
填充:常数边集全部(16.0),
子项:TextFormField(
装饰:输入装饰(标签文本:“电话”),
),
),
),
],
),

多亏了@danish-khan-I,我用
crossAxisAlignment:crossAxisAlignment.baseline
解决了这个问题。但是您还必须提供
textbreeline
,否则它会给出一个异常

因此,在我这一行中,我使用了:

crossAxisAlignment: CrossAxisAlignment.baseline
textBaseline: TextBaseline.ideographic,

不要忘记添加小部件的代码。在
行()
小部件中,您可以使用
crossAxisAlignment:crossAxisAlignment.baseline
@danish-khan-I crossAxisAlignment!=I/颤振(2417):CrossAxisAlignment.baseline | | textBaseline!=null':不正确。感谢
textbreeline
提示