Android 即使在输入后,复选框也会自动设置为初始值。颤振
我正在构建一个应用程序,在这个应用程序中,用户应该在问题中被标记,不管怎样,我设法获得了数组,或者必须说是选中用户的列表,但是在UI中,当用户按下复选框时,复选框不会保持选中状态。它将保持选中状态一段时间,然后自动取消选中。复选框的初始阶段是哪个 我曾尝试使用gridview builder构建列表,但没有成功,因为我无法从中获取已检查用户的列表,因为我不知道如何执行该操作 以下是我正在尝试使用的代码:Android 即使在输入后,复选框也会自动设置为初始值。颤振,android,flutter,dart,checkboxlist,Android,Flutter,Dart,Checkboxlist,我正在构建一个应用程序,在这个应用程序中,用户应该在问题中被标记,不管怎样,我设法获得了数组,或者必须说是选中用户的列表,但是在UI中,当用户按下复选框时,复选框不会保持选中状态。它将保持选中状态一段时间,然后自动取消选中。复选框的初始阶段是哪个 我曾尝试使用gridview builder构建列表,但没有成功,因为我无法从中获取已检查用户的列表,因为我不知道如何执行该操作 以下是我正在尝试使用的代码: Widget build(BuildContext context) { retur
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title ?? "Test"),
),
body: Container(
child: FutureBuilder(
future: _getUsers(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
//print(snapshot.data);
if (snapshot.data == null) {
return Container(child: Center(child: Text("Loading...")));
} else {
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (BuildContext context, int index) {
bool check = snapshot.data[index].istagged;
return CheckboxListTile(
title: Text(snapshot.data[index].name ?? "test"),
value: check,
subtitle:
Text(snapshot.data[index].autouid.toString() ?? "Test"),
onChanged: (bool value) {
setState(() => snapshot.data[index].istagged = value);
if (value == true) {
userid.add(snapshot.data[index].autouid);
check = value;
}
print(userid);
},
);
},
);
}
},
),
),
);
}
我希望选中userid列表,并希望在用户选中复选框时保留UI。该复选框不应自动更改。非常感谢您在这方面的帮助。多谢各位