使用 Transform.translate
Transform.translate(
offset: const Offset(-20, 0),
child: childWidget(),
)
完整示例
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: CheckboxListTile(
value: isChecked,
controlAffinity: ListTileControlAffinity.leading,
contentPadding: EdgeInsets.zero,
title: Transform.translate(
offset: const Offset(-20, 0),
child: RichText(
text: TextSpan(
text: S.of(context).iAgreeWith,
style: TextStyle(
color: Theme.of(context).hintColor,
fontWeight: FontWeight.w400),
children: <TextSpan>[
TextSpan(
text: S.of(context).terms,
style: TextStyle(
decoration: TextDecoration.underline,
color: Theme.of(context).hintColor,
fontWeight: FontWeight.w400),
recognizer: TapGestureRecognizer()
..onTap = () {
// Single tapped.
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => WebView(
url:
ksportsCornerWebsitePolicyUrl,
title: S.of(context).termsCap,
),
));
},
),
TextSpan(
text: " " + S.of(context).and + " ",
style: TextStyle(
color: Theme.of(context).hintColor,
fontWeight: FontWeight.w400)),
TextSpan(
text: S.of(context).privacyPolicy,
style: TextStyle(
decoration: TextDecoration.underline,
color: Theme.of(context).hintColor,
//fontSize: 14.0.sp,
fontWeight: FontWeight.w400),
recognizer: TapGestureRecognizer()
..onTap = () {
// Single tapped.
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => WebView(
url:
ksportsCornerWebsitePolicyUrl,
title: S
.of(context)
.privacyPolicyCaps,
),
));
},
),
],
),
),
),
activeColor: Theme.of(context).hintColor,
checkColor: Theme.of(context).cursorColor,
onChanged: (value) {
isChecked = !isChecked;
setState(() {});
},
),
),