diff --git a/lib/checklist_item.dart b/lib/checklist_item.dart new file mode 100644 index 0000000000000000000000000000000000000000..00137a2f827ca6feedeb2a7f5dee87473e81853c --- /dev/null +++ b/lib/checklist_item.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; + +class ChecklistItem extends StatefulWidget { + final String title; + const ChecklistItem({Key? key, required this.title}) : super(key: key); + @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 : TextDecoration.none, + ), + ), + ), + ); + } +} diff --git a/lib/checklist_view.dart b/lib/checklist_view.dart new file mode 100644 index 0000000000000000000000000000000000000000..c377ae658f126612334d7fc8c709f19b86d26fbc --- /dev/null +++ b/lib/checklist_view.dart @@ -0,0 +1,28 @@ +// checklist_view.dart + +import 'package:flutter/material.dart'; +import 'package:my_flutter_app/checklist_item.dart'; + +class ChecklistView extends StatefulWidget { + @override + State<StatefulWidget> createState() => _ChecklistView(); +} + +class _ChecklistView extends State<ChecklistView> { + List<String> checklist = ["실전코딩 과제", "실전코딩 복습", "댄스파티"]; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('checklist')), + + 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 7036a384ddb7f0c7b90f903d7779c422f05dcf62..60612342723235e2ea30303ae5129527cbca5b41 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,7 @@ // main.dart import 'package:flutter/material.dart'; +import 'package:my_flutter_app/checklist_view.dart'; void main() { runApp(const MyApp()); @@ -25,45 +26,25 @@ class MyHomePage extends StatefulWidget { } class _MyHomePage extends State<MyHomePage> { + void _moveView() { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => ChecklistView()), + ); + } + @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text(widget.title)), body: Container( - margin: EdgeInsets.all(20), - - padding: EdgeInsets.symmetric(vertical: 20, horizontal: 20), - - child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - - children: [ - Container( - width: 200, - height: 100, - - decoration: BoxDecoration( - border: Border.all(color: Colors.black, width: 2), - ), - - child: Text('text in box'), - ), - - Text('text outside of box'), - - Row( - mainAxisAlignment: MainAxisAlignment.start, - - children: [ - Text('text in Row'), - - Container(width: 100, height: 100, child: Icon(Icons.flag)), - ], - ), - ], + child: GestureDetector( + onTap: _moveView, + child: Container( + height: 40, + width: 40, + decoration: BoxDecoration(border: Border.all(color: Colors.black)), ), ), ),