728x90
CheckTileList 를 사용할 때마다 문제점이 생기는데,
이렇게 사용하면 문제 될 일이 없어보인다.
https://api.flutter-io.cn/flutter/material/CheckboxListTile-class.html
class LabeledCheckbox extends StatelessWidget {
const LabeledCheckbox({
super.key,
required this.label,
required this.padding,
required this.value,
required this.onChanged,
});
final String label;
final EdgeInsets? padding;
final bool value;
final ValueChanged<bool> onChanged;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
onChanged(!value);
},
child: Padding(
padding: padding ?? EdgeInsets.symmetric(horizontal: 0, vertical: 0),
child: Row(
children: <Widget>[
Checkbox(
value: value,
onChanged: (bool? newValue) {
onChanged(newValue!);
},
fillColor: MaterialStateProperty.all<Color>(Color(0xFF0A7F39)),
side: BorderSide(width: 1, color: Colors.black),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0),
),
),
Expanded(
child: Text(
label,
style: TextStyle(
color: Colors.black,
fontSize: 16,
fontFamily: 'Pretendard',
fontWeight: FontWeight.w500,
),
)),
],
),
),
);
}
}
728x90
'개발 > Flutter CodeRecipe' 카테고리의 다른 글
Custom TabBar(1) - Text TabBar (0) | 2023.06.23 |
---|