[ad_1]
Any idea how to pass list of seller names coming from database to a dropdown menu?
The get seller from database function:
late String getsellernames = http://ip/sas.php;
var allSellerNames = [];
getSas() async {
var response = await http.get(Uri.parse(getsellernames));
if (response.statusCode == 200) {
setState(() {
allSellerNames = json.decode(response.body);
});
}
print('$allSellerNames');
return allSellerNames;
}
The dropdown
DropdownButtonHideUnderline(
child: DropdownButton(
// hint: const Text('Seller'),
value: allSellerNames[index][0],
items: allSellerNames[index]['seller'].map((ditem) {
return DropdownMenuItem(
child: Text(
ditem,
),
value: ditem,
);
}).toList(),
onChanged: (String? dValue) {
setState(() {
initialnames = dValue!;
});
},
),
),
But I got this error:
The argument type ‘void Function(String?)’ can’t be assigned to the parameter type ‘void Function(Object?)?’
[ad_2]