我在 ListTile 中使用 Checkbox,如下所示:
ListTile(
leading: Checkbox(
value: _isChecked,
onChanged: (v) {
setState(() {
_isChecked = !_isChecked;
});
},
),
title: Text("is Bathroom"),
);
我怎样才能禁用该复选框。我知道复选框小部件是无状态的。但是material子包中是否提供了其他可以做到这一点的Widget。像InputDecorator之类的东西。
我也对 DropdownButton 有同样的问题。我按如下方式使用它从下拉列表中选择表单中的项目。
InputDecorator(
decoration: InputDecoration(
labelText: "Type",
hintText: "Choose the type",
),
isEmpty: _type == null,
child: DropdownButton<int>(
value: _type,
isDense: true,
onChanged: (value) {
setState(() {
_type = value;
});
},
items: _buildDropdownItemList(),
),
);
我尝试了 InputDecoration 中的启用参数,但这只是改变了装饰。用户仍然可以更改选择。