我想从下拉菜单中将数据输入数据库,但是使用此代码时,所有数据都不会进入数据库,例如此代码有问题。这是显示下拉菜单的代码
FutureBuilder(
future: ClientController.getClient(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return new DropdownButton(
hint: Text('Pilih Company'),
value: _selectedClient,
items: snapshot.data
.map<DropdownMenuItem>((value) {
return DropdownMenuItem(
value: value,
child: Text(value["name"]),
);
}).toList(),
onChanged: (value) {
setState(() {
_selectedClient = value;
});
},
);
} else {
return CircularProgressIndicator();
}
}),
,并将此代码输入数据库
if (result) {
final response = await UserController.register({
"username": txtUsername.text,
"password": txtPassword.text,
"email": txtEmail.text,
"full_name": txtFullName.text,
"company": _selectedClient,
});
if (response != null && response["success"]) {
setState(() {});
}
}