我已经在颤振中实现了 CheckboxListTile
。默认复选框为方形。但我需要一个圆形的复选框,就像下图中的那个。有什么办法吗?谢谢你的帮助:)
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
@override
Widget build(BuildContext context) {
return CheckboxListTile(
title: const Text('Animate Slowly'),
value: timeDilation != 1.0,
onChanged: (bool? value) {
setState(() {
timeDilation = value! ? 10.0 : 1.0;
});
},
secondary: const Icon(Icons.hourglass_empty),
);
}
}
答案 0 :(得分:1)
如果你想改变默认的复选框主题,你需要像这样覆盖它
class Exmaple extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final oldCheckboxTheme = theme.checkboxTheme;
final newCheckBoxTheme = oldCheckboxTheme.copyWith(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(100)),
);
return Theme(
data: theme.copyWith(checkboxTheme: newCheckBoxTheme),
child: CheckboxListTile(
onChanged: (_) {},
value: false,
),
);
}
}