-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample2.yaml
80 lines (80 loc) · 2.69 KB
/
example2.yaml
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
StatefulWidget:
name: GeneratedYamlHomePage
state:
- counter:
type: int
defaultValue: 0
- multiplier:
type: String
defaultValue: "''"
functions:
increment: "counter.value += 1;"
decrement: "counter.value -= 1;"
multiply: "multiplier.value = (counter.value * counter.value).toString();"
onDispose:
- "debugPrint('Dispose something else here. State objects are auto disposed now');"
build:
Scaffold:
appBar:
title:
Text:
value: "Flutter From YAML Demo"
floatingActionButton:
extended: true
child:
Row:
children:
- GestureDetector:
bind: true
onTap: "@@function.decrement" #This will be injected since 'bind' is true
child:
Icon:
iconData:
codePoint: 0xe516
- SizedBox:
width: 12
- GestureDetector:
bind: true
onTap: "@@function.increment" #This will be injected since 'bind' is true
child:
Icon:
iconData:
codePoint: 0xe047
- SizedBox:
width: 12
- GestureDetector:
onTap: "multiply();" #This will NOT be injected since 'bind' is not true. Instead, the raw string will be written as onTap
child:
Icon:
iconData:
codePoint: 0xe16a
body:
Center:
child:
Column:
mainAxisAlignment: center
children:
- Text:
value: "Hello from Yaml\\nYou've pressed this button"
textAlign: center
style:
fontSize: 24
fontWeight: 500
- SizedBox:
height: 12
- ListenableBuilder:
listenable: "@@state.counter" #This will be injected
child:
Text:
value: "${counter.value} times"
style:
fontSize: 20
- SizedBox:
height: 12
- ListenableBuilder:
listenable: ["@@state.multiplier", "@@state.counter"] #This will be injected
child:
Text:
value: "${counter.value} x ${counter.value} is ${multiplier.value}"
style:
fontSize: 20