From db75ebfb9450951d1212396ca304abe85d1059f2 Mon Sep 17 00:00:00 2001 From: wonbin <wonbin3977@gmail.com> Date: Wed, 30 Apr 2025 18:07:50 +0900 Subject: [PATCH] checklist_item update --- lib/checklist_item.dart | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/checklist_item.dart b/lib/checklist_item.dart index d875295..cebcc90 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 -- GitLab