Pea*_*Gen 5 mobile android ios flutter
我需要将dropdown我的flutter应用程序的对齐到最右边。它已经对齐,但在我的实际应用程序中,我有多个dropdowns在另一个之下。并非所有下拉菜单中的菜单项长度都相似。所以我需要所有这些都与最右边对齐。
下面是我的代码。
Row(
children: <Widget>[
Expanded(
flex: 1,
child: Container(
margin: EdgeInsets.only(left: 10),
child: Text(
"Size: ",
style: Theme.of(context).textTheme.subhead,
),
),
),
Expanded(
flex: 3,
child: DropdownButton(
hint: Text(
"Please Select ",
style: TextStyle(
fontSize: 14,
),
),
items: <String>[
'Skinless Boneless, Full Loins',
'brown',
'silver'
].map((data) {
return DropdownMenuItem(
child: new Text(data,
style: TextStyle(
fontSize: 14,
)),
value: data,
);
}).toList(),
onChanged: (String newValue) {
setState(() {
_sizedropDown = newValue;
print(newValue);
});
},
value: _sizedropDown,
),
)
],
)
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
Cra*_*Cat 12
设置isExpanded: true在DropdownButton,
Row(
children: <Widget>[
Expanded(
flex: 1,
child: Container(
margin: EdgeInsets.only(left: 10),
child: Text(
"Size: ",
style: Theme.of(context).textTheme.subhead,
),
),
),
Expanded(
flex: 3,
child: DropdownButton<String>(
isExpanded: true,
hint: Text(
"Please Select ",
style: TextStyle(
fontSize: 14,
),
),
items: <String>[
'Skinless Boneless, Full Loins',
'brown',
'silver'
].map((data) {
return DropdownMenuItem(
child: new Text(data,
style: TextStyle(
fontSize: 14,
)),
value: data,
);
}).toList(),
onChanged: (String newValue) {
setState(() {
_sizedropDown = newValue;
print(newValue);
});
},
value: _sizedropDown,
),
)
],
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2227 次 |
| 最近记录: |