1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
| import 'package:flutter/material.dart';
class ChangeTextByButton extends StatefulWidget {
@override
State<StatefulWidget> createState() {
print('createState()'); // 여기 출력!
return _ChangeTextByButton();
}
}
class _ChangeTextByButton extends State<ChangeTextByButton> {
var swVal = false;
var str = 'Jaejin Jang off';
@override
void initState() {
super.initState();
print('initState()'); // 여기 출력!
}
void didChangeDependencies() {
super.didChangeDependencies();
print('didChangeDependencies()'); // 여기 출력!
}
@override
Widget build(BuildContext context) {
print('build'); // 여기 출력!
return MaterialApp(
title: 'ChangeTextByButton',
theme: ThemeData(
primaryColor: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity),
darkTheme: ThemeData.light(),
home: Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
str,
style: TextStyle(color: Colors.blue, fontSize: 20),
),
Switch(
value: swVal,
onChanged: (value) {
setState(() {
swVal = value;
str = value ? 'Jaejin Jang On' : 'Jaejin Jang off';
});
},
),
]))),
);
}
}
|