Skip to content

Commit fcc2936

Browse files
committed
update example
1 parent 2fa50a7 commit fcc2936

File tree

2 files changed

+39
-49
lines changed

2 files changed

+39
-49
lines changed

README.md

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ flexibility, and a very flat code hierarchy than Flex and Stack. Say no to 'nest
99

1010
View [Flutter Web Online Example](https://constraintlayout.flutterfirst.cn)
1111

12-
**Flutter ConstraintLayout has extremely high layout performance because it does not require linear
12+
**Flutter ConstraintLayout has extremely high layout performance. It does not require linear
1313
equations to solve. It is recommended to use ConstraintLayout at the top level. For extremely
1414
complex layout(One thousand child elements, two thousand constraints), layout and drawing total time
1515
within 5 milliseconds(debug mode on Windows 10,release mode take less time), the frame rate can be
@@ -690,7 +690,7 @@ class CirclePositionExampleState extends State<CirclePositionExample> {
690690
void initState() {
691691
super.initState();
692692
calculateClockAngle();
693-
timer = Timer.periodic(const Duration(seconds: 1), (timer) {
693+
timer = Timer.periodic(const Duration(seconds: 1), (_) {
694694
calculateClockAngle();
695695
});
696696
}
@@ -739,39 +739,34 @@ class CirclePositionExampleState extends State<CirclePositionExample> {
739739
translateConstraint: true,
740740
),
741741
for (int i = 0; i < 12; i++)
742-
Container(
743-
alignment: Alignment.center,
744-
child: Text(
745-
'${i + 1}',
746-
style: const TextStyle(
747-
fontWeight: FontWeight.bold,
748-
fontSize: 25,
749-
),
742+
Text(
743+
'${i + 1}',
744+
style: const TextStyle(
745+
fontWeight: FontWeight.bold,
746+
fontSize: 25,
750747
),
751748
).applyConstraint(
752-
width: 50,
753-
height: 50,
754749
centerTo: rId(0),
755750
translate: circleTranslate(
756-
radius: 200,
751+
radius: 205,
757752
angle: (i + 1) * 30,
758753
),
759754
),
760755
for (int i = 0; i < 60; i++)
761-
Transform.rotate(
762-
angle: pi + pi * (i * 6 / 180),
763-
child: Container(
764-
color: Colors.grey,
765-
margin: const EdgeInsets.only(
766-
top: 405,
756+
if (i % 5 != 0)
757+
Transform.rotate(
758+
angle: pi + pi * (i * 6 / 180),
759+
child: Container(
760+
color: Colors.grey,
761+
margin: const EdgeInsets.only(
762+
top: 405,
763+
),
767764
),
765+
).applyConstraint(
766+
width: 1,
767+
height: 415,
768+
centerTo: rId(0),
768769
),
769-
).applyConstraint(
770-
width: 1,
771-
height: 415,
772-
centerTo: rId(0),
773-
visibility: i % 5 == 0 ? gone : visible,
774-
),
775770
Transform.rotate(
776771
angle: pi + pi * (hour * 30 / 180),
777772
alignment: Alignment.topCenter,

example/circle_position.dart

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CirclePositionExampleState extends State<CirclePositionExample> {
2626
void initState() {
2727
super.initState();
2828
calculateClockAngle();
29-
timer = Timer.periodic(const Duration(seconds: 1), (timer) {
29+
timer = Timer.periodic(const Duration(seconds: 1), (_) {
3030
calculateClockAngle();
3131
});
3232
}
@@ -79,39 +79,34 @@ class CirclePositionExampleState extends State<CirclePositionExample> {
7979
translateConstraint: true,
8080
),
8181
for (int i = 0; i < 12; i++)
82-
Container(
83-
alignment: Alignment.center,
84-
child: Text(
85-
'${i + 1}',
86-
style: const TextStyle(
87-
fontWeight: FontWeight.bold,
88-
fontSize: 25,
89-
),
82+
Text(
83+
'${i + 1}',
84+
style: const TextStyle(
85+
fontWeight: FontWeight.bold,
86+
fontSize: 25,
9087
),
9188
).applyConstraint(
92-
width: 50,
93-
height: 50,
9489
centerTo: rId(0),
9590
translate: circleTranslate(
96-
radius: 200,
91+
radius: 205,
9792
angle: (i + 1) * 30,
9893
),
9994
),
10095
for (int i = 0; i < 60; i++)
101-
Transform.rotate(
102-
angle: pi + pi * (i * 6 / 180),
103-
child: Container(
104-
color: Colors.grey,
105-
margin: const EdgeInsets.only(
106-
top: 405,
96+
if (i % 5 != 0)
97+
Transform.rotate(
98+
angle: pi + pi * (i * 6 / 180),
99+
child: Container(
100+
color: Colors.grey,
101+
margin: const EdgeInsets.only(
102+
top: 405,
103+
),
107104
),
105+
).applyConstraint(
106+
width: 1,
107+
height: 415,
108+
centerTo: rId(0),
108109
),
109-
).applyConstraint(
110-
width: 1,
111-
height: 415,
112-
centerTo: rId(0),
113-
visibility: i % 5 == 0 ? gone : visible,
114-
),
115110
Transform.rotate(
116111
angle: pi + pi * (hour * 30 / 180),
117112
alignment: Alignment.topCenter,

0 commit comments

Comments
 (0)