flutter - 如何将两个小部件放置在同一行中?
问题描述
我有国家代码(DropdownMenu)和电话(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"),
),
),
),
],
),
解决方案
感谢@danish-khan-I,我解决了使用crossAxisAlignment: CrossAxisAlignment.baseline
. 但是你也必须提供,textBaseline
否则它会给出一个例外。
所以在我的行中我使用过:
crossAxisAlignment: CrossAxisAlignment.baseline
textBaseline: TextBaseline.ideographic,
推荐阅读
- windows - 未找到 Docker entrypoint.sh
- delphi - Delphi 7 - DCPCrypt - TDCP_rijndael - DecryptString - 如何让它工作?
- javascript - 如何在不加密输入的情况下提交表单?
- c# - 如何将十六进制写入二进制文件c#的文本部分
- reactjs - 如何在不触发 onChange 的情况下将更改应用于 slatejs react 编辑器?
- r - 在 R 中为不同的绘图方案拆分绘图窗格
- mongodb - 如何将训练好的张量流模型存储在数据库中
- css - 使用线性渐变创建的背景的边框半径
- javascript - Sharepoint 2013 工作流程:从代码启动时如何发送一个人作为启动参数
- c# - 如何在 .NET Core 的 appSettings.json 上配置 IdentityServer 设置?