xxxxxxxxxx
Card(
elevation: 1,
margin: EdgeInsets.only(bottom: 3),
child: ListTile(
title: Text("Item Type"),
contentPadding: EdgeInsets.fromLTRB(10, 0, 10, 0),
trailing: DropdownButtonHideUnderline(
child: DropdownButton(
isExpanded: false,
value: true,
items: itemTypeList.map((item) {
return new DropdownMenuItem(
child: Container(
width: 150, //expand here
child: new Text(
item['item_name'],
textAlign: TextAlign.end,
),
),
value: item['item_id'],
);
}).toList(),
onChanged: (value) {
setState(() {
selectedLeaveType = value;
});
},
hint: Container(
width: 150, //and here
child: Text(
"Select Item Type",
style: TextStyle(color: Colors.grey),
textAlign: TextAlign.end,
),
),
style:
TextStyle(color: Colors.black, decorationColor: Colors.red),
),
),
),
),
DropdownButton in flutter with initial value, hintText, right/end icon, border and more
xxxxxxxxxx
>>>>Initialize the following in your state class
List<String> dropDownMenuItem = ["Option 1", "Option2"];
String? selectedValue;
>>>>Your main DropdownButton
Container(
margin: getMargin(top: 16),
child: SizedBox(
width: double.infinity,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
border:
Border.all(color: appTheme.gray30003)),
child: DropdownButton<String>(
isExpanded: true,
hint: Text(
"Select an option",
style: theme.textTheme.bodySmall!.copyWith(
color: appTheme.black900,
fontSize: getFontSize(
13,
),
),
),
style: TextThemeHelper.bodySmallBluegray40012,
icon: const Icon(Icons.expand_more_outlined),
padding: EdgeInsets.symmetric(
vertical: 1, horizontal: 20),
underline: SizedBox.shrink(),
value: selectedValue,
items: dropDownMenuItem
.map((String e) => DropdownMenuItem(
value: e, child: Text(e)))
.toList(),
onChanged: (String? value) {
setState(() {
selectedValue = value!;
});
}),
),
),
),