Skip to content
Snippets Groups Projects
Commit d5ba296d authored by JM-220's avatar JM-220
Browse files

fourth

parent 0d24d5e6
No related branches found
No related tags found
No related merge requests found
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,
),
),
),
);
}
}
// 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]);
}),
),
),
);
}
}
// main.dart // main.dart
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:my_flutter_app/checklist_view.dart';
void main() { void main() {
runApp(const MyApp()); runApp(const MyApp());
...@@ -25,45 +26,25 @@ class MyHomePage extends StatefulWidget { ...@@ -25,45 +26,25 @@ class MyHomePage extends StatefulWidget {
} }
class _MyHomePage extends State<MyHomePage> { class _MyHomePage extends State<MyHomePage> {
void _moveView() {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ChecklistView()),
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: Text(widget.title)), appBar: AppBar(title: Text(widget.title)),
body: Container( body: Container(
margin: EdgeInsets.all(20), child: GestureDetector(
onTap: _moveView,
padding: EdgeInsets.symmetric(vertical: 20, horizontal: 20), child: Container(
height: 40,
child: Center( width: 40,
child: Column( decoration: BoxDecoration(border: Border.all(color: Colors.black)),
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)),
],
),
],
), ),
), ),
), ),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment