@@ -28,6 +28,7 @@ ConstraintLayout will only be measured once, This results in extremely high layo
28
28
8 . translate
29
29
9 . percentage layout
30
30
10 . guideline
31
+ 11 . constraints and widgets separation
31
32
32
33
Coming soon:
33
34
@@ -74,6 +75,7 @@ class ExampleState extends State<Example> {
74
75
double x = 0;
75
76
double y = 0;
76
77
78
+ ConstraintId box0 = ConstraintId();
77
79
ConstraintId box1 = ConstraintId();
78
80
ConstraintId box2 = ConstraintId();
79
81
ConstraintId box3 = ConstraintId();
@@ -92,22 +94,43 @@ class ExampleState extends State<Example> {
92
94
home : Scaffold(
93
95
backgroundColor : Colors.black,
94
96
body : ConstraintLayout(
97
+ // Constraints can be separated from widgets
98
+ childConstraints : [
99
+ Constraint(
100
+ id : box0,
101
+ width : 200,
102
+ height : 200,
103
+ bottomLeftTo : parent,
104
+ zIndex : 20,
105
+ )
106
+ ],
95
107
children : [
108
+ Container(
109
+ color : Colors.redAccent,
110
+ alignment : Alignment.center,
111
+ child : const Text('box0'),
112
+ ).applyConstraintId(
113
+ id : box0, // Constraints can be separated from widgets
114
+ ),
96
115
Container(
97
116
color : Colors.redAccent,
98
117
alignment : Alignment.center,
99
118
child : const Text('box1'),
100
- ).applyConstraint(
101
- id : box1,
102
- width : 200,
103
- height : 100,
104
- topRightTo : parent,
119
+ ).apply(
120
+ constraint : Constraint(
121
+ // Constraints set with widgets
122
+ id : box1,
123
+ width : 200,
124
+ height : 100,
125
+ topRightTo : parent,
126
+ ),
105
127
),
106
128
Container(
107
129
color : Colors.blue,
108
130
alignment : Alignment.center,
109
131
child : const Text('box2'),
110
132
).applyConstraint(
133
+ // Constraints set with widgets easy way
111
134
id : box2,
112
135
width : matchConstraint,
113
136
height : matchConstraint,
@@ -207,7 +230,7 @@ class ExampleState extends State<Example> {
207
230
baseline : box7.baseline,
208
231
left : box7.left,
209
232
),
210
- ...hChain (
233
+ ...horizontalChain (
211
234
centerHorizontalTo : parent,
212
235
hChainList : [
213
236
Container(
@@ -245,7 +268,6 @@ class ExampleState extends State<Example> {
245
268
horizontalBias : 0,
246
269
verticalBias : 0,
247
270
centerTo : parent,
248
- zIndex : 6,
249
271
),
250
272
],
251
273
),
0 commit comments