From dc69b6feca13535026417dd516940e39f5c8b6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=8B=A4=EC=9D=80?= <daeun@gimda-eun-ui-MacBookAir.local> Date: Wed, 30 Apr 2025 18:09:12 +0900 Subject: [PATCH] checklist --- lib/checklist_Item.dart | 35 +++++++++++++++++++++++++++++++++++ lib/checklist_view.dart | 22 +++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 lib/checklist_Item.dart diff --git a/lib/checklist_Item.dart b/lib/checklist_Item.dart new file mode 100644 index 0000000..916518d --- /dev/null +++ b/lib/checklist_Item.dart @@ -0,0 +1,35 @@ +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; + }); + } + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: _check, + child: Container( + height: 32, + child: Text(widget.title, + style: TextStyle( + color: _isChecked ? Colors.grey : Colors.black, + decoration: _isChecked ? TextDecoration.lineThrough : null + ),), + ), + ); + } +} \ No newline at end of file diff --git a/lib/checklist_view.dart b/lib/checklist_view.dart index 3e8d32e..770d4b7 100644 --- a/lib/checklist_view.dart +++ b/lib/checklist_view.dart @@ -1,5 +1,6 @@ // checklist_view.dart import 'package:flutter/material.dart'; +import 'package:flutter_application_0430/checklist_Item.dart'; class ChecklistView extends StatefulWidget { const ChecklistView({super.key}); @@ -9,12 +10,31 @@ class ChecklistView extends StatefulWidget { } class _ChecklistViewState extends State<ChecklistView> { + + + List<String> checkList = [ + "실전코딩 플러터 기본 과제", + "PPT 만들기", + "재맞고 수료증 출력 후 제출" + ]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('checklist')), - body: Container(), + body: Container( + width: MediaQuery.of(context).size.width, + margin: EdgeInsets.symmetric(horizontal: 40,vertical: 20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: List<Widget>.generate(checkList.length,(index) { + return CheckListItem(title: checkList[index]); + },), + ), + ), ); } } +class string { +} + -- GitLab