@@ -15,14 +15,17 @@ class TranslateExample extends StatefulWidget {
1515class TranslateExampleState extends State <TranslateExample > {
1616 late Timer timer;
1717 int angle = 0 ;
18+ int earthAngle = 0 ;
1819
1920 @override
2021 void initState () {
2122 super .initState ();
2223 timer = Timer .periodic (const Duration (milliseconds: 16 ), (_) {
2324 setState (() {
24- angle++ ;
25+ angle += 5 ;
2526 angle %= 360 ;
27+ earthAngle += 1 ;
28+ earthAngle %= 360 ;
2629 });
2730 });
2831 }
@@ -43,12 +46,68 @@ class TranslateExampleState extends State<TranslateExample> {
4346 ),
4447 body: ConstraintLayout (
4548 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+ ),
46105 Container (
47106 color: Colors .yellow,
48107 ).applyConstraint (
49108 id: anchor,
50109 size: 150 ,
51- centerTo : parent,
110+ centerRightTo : parent. rightMargin ( 300 ) ,
52111 ),
53112 Container (
54113 color: Colors .red,
0 commit comments