Skip to content
Snippets Groups Projects
Commit dc69b6fe authored by 김다은's avatar 김다은
Browse files

checklist

parent ee6b8a7a
Branches
No related tags found
No related merge requests found
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
// 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 {
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment