diff --git a/lib/checklist_item.dart b/lib/checklist_item.dart index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..602beec7cdbf87c51d1efe7b4da645affe588fc6 100644 --- a/lib/checklist_item.dart +++ 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( + child: Text( + widget.title, + style: TextStyle( + color: _isChecked ? Colors.grey : Colors.black, + decoration: _isChecked ? TextDecoration.lineThrough : null, + ), + ), + ), + ); + } +} diff --git a/lib/checklist_view.dart b/lib/checklist_view.dart index 1692fa46089cfa98705d7fdec34d55f959ee1e6a..09a104eea74f585edb5f63917b143a84694a47d0 100644 --- a/lib/checklist_view.dart +++ b/lib/checklist_view.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:second_flutter/checklist_item.dart'; class ChecklistView extends StatefulWidget { @override @@ -8,11 +9,19 @@ class ChecklistView extends StatefulWidget { } class _ChecklistView extends State<ChecklistView> { + List<String> checklist = ["집가고싶다", "과제해야돼", "으아아아악"]; + @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('checklist')), - body: Container(), + body: Container( + child: Column( + children: List<Widget>.generate(checklist.length, (index) { + return ChecklistItem(title: checklist[index]); + }), + ), + ), ); } } diff --git a/lib/main.dart b/lib/main.dart index a58831b50deb18781e02d4e709a15e04e0aea188..45c59217534dfdf0e7b1d159d1914a4be8e77f0e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,6 @@ // main.dart import 'package:flutter/material.dart'; -import 'package:second_flutter/checklist_item.dart'; import 'package:second_flutter/checklist_view.dart'; void main() {