【发布时间】:2019-02-09 22:44:27
【问题描述】:
我在 ListTile 中使用 Checkbox,如下所示:
ListTile(
leading: Checkbox(
value: _isChecked,
onChanged: (v) {
setState(() {
_isChecked = !_isChecked;
});
},
),
title: Text("is Bathroom"),
);
如何禁用该复选框。我知道 Checkbox 小部件是无状态的。但是材料子包中是否提供了其他任何 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 中尝试了 enable 参数,但这只是改变了装饰。用户仍然可以更改选择。
【问题讨论】:
标签: dart flutter flutter-layout