diff --git a/lib/checklist_item.dart b/lib/checklist_item.dart index d8752956807d0b9377dcef323edaaa5bae116f37..cebcc90c645de99242e0b4acf445525d1a0c0086 100644 --- a/lib/checklist_item.dart +++ b/lib/checklist_item.dart @@ -5,18 +5,40 @@ import 'package:flutter/material.dart'; class ChecklistItem extends StatefulWidget { final String title; ChecklistItem({required this.title}); + @override State<StatefulWidget> createState() => _ChecklistItem(); } class _ChecklistItem extends State<ChecklistItem> { + bool _isChecked = false; + + void _Check() { + setState(() { + _isChecked = !_isChecked; + }); + if (_isChecked) { + print('체크됨'); + } else { + print('체크 해제됨'); + } + } + @override Widget build(BuildContext context) { return GestureDetector( + onTap: _Check, child: Container( - child: Text('widget.title'), - ) + padding: const EdgeInsets.all(8.0), + child: Text( + widget.title, // 문자열 처리 수정 + style: TextStyle( + fontSize: 20, + color: _isChecked ? Colors.green : Colors.black, + decoration: _isChecked ? TextDecoration.lineThrough : TextDecoration.none, // Null 대신 TextDecoration.none 사용 + ), + ), + ), ); } -} - +} \ No newline at end of file