gpt4 book ai didi

flutter - 如何在Flutter中正确设置复选框边距或填充的图像和文本

转载 作者:行者123 更新时间:2023-12-03 03:33:12 29 4
gpt4 key购买 nike

我有一个Check box作为以下代码:

DelayedAnimation(
child: CheckboxListTile(
title: const Text('Check privacy & policy'),
value: timeDilation != 1.0,
onChanged: (bool value) {
setState(() {
timeDilation = value ? 5.0 : 1.0;
});
},
secondary: Image.asset(
'assets/images/policy_ic.png',
height: 30,
),
),
delay: delayedAmount + 4500,
),
如下图所示:
cb1
现在,我需要为 text和image设置padding或margin,使其类似于下图:
cb2
希望有人可以帮助我解决这个问题。

最佳答案

我将使用一行而不是CheckboxListTile:

Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Image.asset(
'assets/images/policy_ic.png',
height: 30,
),
Container(
margin: EdgeInsets.all(10),
child: Text(
'Check privacy & policy',
style: Theme.of(context).textTheme.headline5,
),
),
Checkbox(
value: timeDilation != 1.0,
onChanged: (bool value) {
setState(() {
timeDilation = value ? 5.0 : 1.0;
});
}),
],
)
编辑:
创建一个自定义小部件,如下所示:
class CustomTile extends StatefulWidget {
@override
_CustomTileState createState() => _CustomTileState();
}

class _CustomTileState extends State<CustomTile> {
bool value = false;

@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
setState(() {
value = !value;
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Icon(Icons.extension),
Container(
margin: EdgeInsets.all(10),
child: Text(
'Check privacy & policy',
style: Theme.of(context).textTheme.headline5,
),
),
Checkbox(
value: value,
onChanged: (bool value) {},
)
],
),
);
}
}

关于flutter - 如何在Flutter中正确设置复选框边距或填充的图像和文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62597295/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com