0

我想将下拉菜单中的数据输入数据库,但是使用此代码时,所有数据都不会进入数据库,就像此代码有问题一样。这是显示下拉菜单的代码

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(() {});
    }
}
4

0 回答 0