@@ -15,14 +15,17 @@ class TranslateExample extends StatefulWidget {
15
15
class TranslateExampleState extends State <TranslateExample > {
16
16
late Timer timer;
17
17
int angle = 0 ;
18
+ int earthAngle = 0 ;
18
19
19
20
@override
20
21
void initState () {
21
22
super .initState ();
22
23
timer = Timer .periodic (const Duration (milliseconds: 16 ), (_) {
23
24
setState (() {
24
- angle++ ;
25
+ angle += 5 ;
25
26
angle %= 360 ;
27
+ earthAngle += 1 ;
28
+ earthAngle %= 360 ;
26
29
});
27
30
});
28
31
}
@@ -43,12 +46,68 @@ class TranslateExampleState extends State<TranslateExample> {
43
46
),
44
47
body: ConstraintLayout (
45
48
children: [
49
+ Container (
50
+ decoration: const BoxDecoration (
51
+ color: Colors .redAccent,
52
+ borderRadius: BorderRadius .all (Radius .circular (1000 )),
53
+ ),
54
+ child: const Text ('Sun' ),
55
+ alignment: Alignment .center,
56
+ ).applyConstraint (
57
+ size: 200 ,
58
+ pinnedInfo: PinnedInfo (
59
+ parent,
60
+ Anchor (0.5 , AnchorType .percent, 0.5 , AnchorType .percent),
61
+ Anchor (0.3 , AnchorType .percent, 0.5 , AnchorType .percent),
62
+ ),
63
+ ),
64
+ Container (
65
+ decoration: const BoxDecoration (
66
+ color: Colors .blue,
67
+ borderRadius: BorderRadius .all (Radius .circular (1000 )),
68
+ ),
69
+ child: const Text ('Earth' ),
70
+ alignment: Alignment .center,
71
+ ).applyConstraint (
72
+ size: 100 ,
73
+ pinnedInfo: PinnedInfo (
74
+ sId (- 1 ),
75
+ Anchor (0.5 , AnchorType .percent, 0.5 , AnchorType .percent),
76
+ Anchor (0.5 , AnchorType .percent, 0.5 , AnchorType .percent),
77
+ angle: earthAngle,
78
+ ),
79
+ translate: circleTranslate (
80
+ radius: 350 ,
81
+ angle: earthAngle,
82
+ ),
83
+ translateConstraint: true ,
84
+ ),
85
+ Container (
86
+ decoration: const BoxDecoration (
87
+ color: Colors .grey,
88
+ borderRadius: BorderRadius .all (Radius .circular (1000 )),
89
+ ),
90
+ child: const Text ('Moon' ),
91
+ alignment: Alignment .center,
92
+ ).applyConstraint (
93
+ size: 50 ,
94
+ pinnedInfo: PinnedInfo (
95
+ sId (- 1 ),
96
+ Anchor (0.5 , AnchorType .percent, 0.5 , AnchorType .percent),
97
+ Anchor (0.5 , AnchorType .percent, 0.5 , AnchorType .percent),
98
+ angle: angle,
99
+ ),
100
+ translate: circleTranslate (
101
+ radius: 100 ,
102
+ angle: angle,
103
+ ),
104
+ ),
46
105
Container (
47
106
color: Colors .yellow,
48
107
).applyConstraint (
49
108
id: anchor,
50
109
size: 150 ,
51
- centerTo : parent,
110
+ centerRightTo : parent. rightMargin ( 300 ) ,
52
111
),
53
112
Container (
54
113
color: Colors .red,
0 commit comments