i am trying to make dropdownbutton with using my CustomerModel model instances but i am getting same error again and again . i tried override == operator and add hashcode method for that class but it didn’t fix that error . What can i do for fix this error ?
Expanded(
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(5),
border: Border.all(color: softColor)),
child: DropdownButton<CustomerModel?>(
dropdownColor: Colors.white,
onChanged: (CustomerModel? value) {
setState(
() {
selectedCustomer = value!;
},
);
},
borderRadius: BorderRadius.circular(5),
isExpanded: true,
icon: Icon(
Icons.arrow_drop_down,
color: softColor,
),
value:
selectedCustomer ?? allCustomers[0],
items: List.generate(
allCustomers.length,
(index) =>
DropdownMenuItem<CustomerModel>(
child: CustomTextBody(
text:
allCustomers[index].companyName,
),
),
),
),
),
),
i tried create dropdownbutton with my class instances but i got error
>Solution :
DropdownMenuItem is missing value
for your case.
DropdownMenuItem(
value: allCustomers[index], //this one