I need to align the dropdown
of my flutter
application to the far right. It is already aligned, but in my real application I have multiple dropdowns
one below another. The menu item length will not be similar in all dropdowns. So I need all of these aligned to the far right.
Below is my code.
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,
),
)
],
)
How can I do this?
Set isExpanded: true
in 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,
),
)
],
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With