在 Flutter 中,如何通过 checklisttile 使单个选项卡击键成为选项卡?
In Flutter, how to make single tab keystroke to tab through checklisttile?
目前,我必须按 Tab 键两次(两次 Tab 键击)才能“通过 Tab 键浏览”复选框 (checklisttile)。
我只想强制执行一次 Tab 键击以在复选框中使用 Tab 键,就像在文本表单域中使用 Tab 键一样。你如何做到这一点?我试过用焦点小部件包装 checklisttile,并将 focusnode 也插入到 checklisttile 中。
CheckboxListTile(
contentPadding: EdgeInsets.zero,
title: new RichText(
text: new TextSpan(children: <InlineSpan>[
TextSpan(
text: 'I understand and agree to the ',
style: TextStyle(color: Colors.black87)),
TextSpan(
recognizer: TapGestureRecognizer()
..onTap = () {
Slideout(
context: context,
title: widget.slideOutTitle != null
? widget.slideOutTitle
: "Terms and Conditions",
child: ListView(
shrinkWrap: true,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(30, 20, 30, 0),
child: Column(children: [
widget.dialogTextWidget,
SizedBox(height: 20),
ButtonWidget(
labelText: "Agree",
onPress: () {
setState(() {
consentCheckedValue = true;
_isDisabled = false;
});
Navigator.pop(context);
}),
]),
)
],
));
},
text: 'Terms and Conditions.',
style: TextStyle(
color: Theme.of(context).primaryColor, fontWeight: FontWeight.bold)),
])),
value: consentCheckedValue,
onChanged: (newValue) {
setState(() {
consentCheckedValue = newValue!;
_isDisabled = !newValue;
});
},
controlAffinity: ListTileControlAffinity.leading,
)
您可以在 CheckboxListTile
中使用自定义 focusNode
,启用 skipTraversal
:
CheckboxListTile(
...,
focusNode: FocusNode(skipTraversal: true),
);
目前,我必须按 Tab 键两次(两次 Tab 键击)才能“通过 Tab 键浏览”复选框 (checklisttile)。
我只想强制执行一次 Tab 键击以在复选框中使用 Tab 键,就像在文本表单域中使用 Tab 键一样。你如何做到这一点?我试过用焦点小部件包装 checklisttile,并将 focusnode 也插入到 checklisttile 中。
CheckboxListTile(
contentPadding: EdgeInsets.zero,
title: new RichText(
text: new TextSpan(children: <InlineSpan>[
TextSpan(
text: 'I understand and agree to the ',
style: TextStyle(color: Colors.black87)),
TextSpan(
recognizer: TapGestureRecognizer()
..onTap = () {
Slideout(
context: context,
title: widget.slideOutTitle != null
? widget.slideOutTitle
: "Terms and Conditions",
child: ListView(
shrinkWrap: true,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(30, 20, 30, 0),
child: Column(children: [
widget.dialogTextWidget,
SizedBox(height: 20),
ButtonWidget(
labelText: "Agree",
onPress: () {
setState(() {
consentCheckedValue = true;
_isDisabled = false;
});
Navigator.pop(context);
}),
]),
)
],
));
},
text: 'Terms and Conditions.',
style: TextStyle(
color: Theme.of(context).primaryColor, fontWeight: FontWeight.bold)),
])),
value: consentCheckedValue,
onChanged: (newValue) {
setState(() {
consentCheckedValue = newValue!;
_isDisabled = !newValue;
});
},
controlAffinity: ListTileControlAffinity.leading,
)
您可以在 CheckboxListTile
中使用自定义 focusNode
,启用 skipTraversal
:
CheckboxListTile(
...,
focusNode: FocusNode(skipTraversal: true),
);