![](/img/trans.png)
[英]How to make Checkbox shape rounded in CheckboxListTile in Flutter?
[英]How to make a "link" from CheckboxlistTile to another page on Flutter
我正在制定條款和條件協議,我希望突出顯示並可點擊這句話,點擊后應該將用戶帶到應用程序中的另一個頁面,他們可以在其中閱讀協議。 我在創建既可點擊又突出顯示的內容時遇到問題。
這是我的代碼:
CheckboxListTile(
value: checkboxValue,
onChanged: (val) {
if (checkboxValue == false) {
setState(() {
checkboxValue = true;
});
} else if (checkboxValue == true) {
setState(() {
checkboxValue = false;
});
}
},
subtitle: !checkboxValue
? Text(
'Required.',
style: TextStyle(color: Colors.red),
)
: null,
title: new Text(
'I agree to the Terms and Conditions.',
style: TextStyle(fontSize: 14.0),
),
controlAffinity: ListTileControlAffinity.leading,
activeColor: Colors.green,
),
```
用GestureDetector()
包裝您的 Text 小部件。 見下面的代碼
CheckboxListTile(
value: checkboxValue,
onChanged: (val) {
setState(() {
checkboxValue = !checkboxValue;
});
},
subtitle: !checkboxValue
? Text(
'Required.',
style: TextStyle(color: Colors.red),
)
: null,
title: GestureDetector(
onTap: (){
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context){
return Page();
},
),
);
},
child: Text(
'I agree to the Terms and Conditions.',
style: TextStyle(fontSize: 14.0),
),
),
controlAffinity: ListTileControlAffinity.leading,
activeColor: Colors.green,
)
使用Inkwell
或GestureDetector
包裹您的文本。
示例代碼在這里:
GestureDetector(
onTap: () { },
child: Text(
"Sample Text",
style: TextStyle(
fontWeight: FontWeight.w800, color: Colors.blue
),
),
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.