[英]How to make Checkbox shape rounded in CheckboxListTile in Flutter?
[英]How to make checkbox ListTile with rounded box using Getx in Flutter
您可以使用shape字段和CircleBorder class 或RoundedRectangleBorder來制作一個 CheckBox 圓形(如果您希望它們具有圓角):
Checkbox(
checkColor: Colors.white,
value: isChecked,
shape: CircleBorder(),
onChanged: (bool? value) {
setState(() {
isChecked = value!;
});
},
);
或者:
Checkbox(
checkColor: Colors.white,
value: isChecked,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(5.0))),
onChanged: (bool? value) {
setState(() {
isChecked = value!;
});
},
);
要使用 GetX,我認為您應該提供一些代碼或示例來解釋您的意思以及您想要准確實現的目標,否則最好的建議可能是閱讀文檔並檢查一些示例。
正如您在屏幕截圖中提到的那樣。 您可以使用 GetX 實現它,如下所示:
創建一個變量以跟蹤檢查的值
final Rxn<int> selected = Rxn<int>();
現在您必須使用Obx小部件實現 UI 以偵聽觀察變量 ' selected ' 的變化
Obx( () => Column( children: [ CheckboxListTile( title: const Text('This is the title 1'), subtitle: const Text('This is the subtitle with ID 1'), checkColor: Colors.white, activeColor: Colors.blueGrey, controlAffinity: ListTileControlAffinity.leading, checkboxShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)), value: selected.value == 1, onChanged: (val) { val?? true? selected.value = 1: selected.value = null; }, ), CheckboxListTile( title: const Text('This is the title 2'), subtitle: const Text('This is the subtitle with ID 2'), checkColor: Colors.white, activeColor: Colors.blueGrey, controlAffinity: ListTileControlAffinity.leading, checkboxShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)), value: selected.value == 2, onChanged: (val) { val?? true? selected.value = 2: selected.value = null; }, ), ], ), ))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.