Skip to content

Commit 09bfdd4

Browse files
committed
add complex list example
1 parent 05b09a1 commit 09bfdd4

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed

assets/3x/test.png

430 KB
Loading

assets/3x/test2.png

327 KB
Loading

example/complex_list.dart

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import 'package:flutter/cupertino.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:flutter_constraintlayout/flutter_constraintlayout.dart';
4+
5+
class ComplexListExample extends StatelessWidget {
6+
const ComplexListExample({Key? key}) : super(key: key);
7+
8+
@override
9+
Widget build(BuildContext context) {
10+
TextStyle style = const TextStyle(
11+
color: Colors.white,
12+
);
13+
List<Color> colors = [
14+
Colors.redAccent,
15+
Colors.orangeAccent,
16+
Colors.deepPurpleAccent,
17+
Colors.black,
18+
Colors.cyan,
19+
Colors.pink,
20+
];
21+
return MaterialApp(
22+
home: Scaffold(
23+
body: ListView.builder(
24+
itemBuilder: (context, index) {
25+
return Container(
26+
child: ConstraintLayout(
27+
children: [
28+
Image.asset(
29+
'assets/test.png',
30+
fit: BoxFit.fill,
31+
).applyConstraint(
32+
width: 100,
33+
height: wrapContent,
34+
centerLeftTo: parent,
35+
),
36+
Image.asset(
37+
'assets/test2.png',
38+
fit: BoxFit.fill,
39+
).applyConstraint(
40+
width: 150,
41+
height: wrapContent,
42+
centerRightTo: parent,
43+
),
44+
Text(
45+
'topLeft $index',
46+
style: style,
47+
).applyConstraint(
48+
topLeftTo: parent,
49+
),
50+
Text(
51+
'topCenter $index',
52+
style: style,
53+
).applyConstraint(
54+
topCenterTo: parent,
55+
),
56+
Text(
57+
'topRight $index',
58+
style: style,
59+
).applyConstraint(
60+
topRightTo: parent,
61+
),
62+
Text(
63+
'centerLeft $index',
64+
style: style,
65+
).applyConstraint(
66+
centerLeftTo: parent,
67+
),
68+
Text(
69+
'center $index',
70+
style: style,
71+
).applyConstraint(
72+
centerTo: parent,
73+
),
74+
Text(
75+
'centerRight $index',
76+
style: style,
77+
).applyConstraint(
78+
centerRightTo: parent,
79+
),
80+
Text(
81+
'bottomLeft $index',
82+
style: style,
83+
).applyConstraint(
84+
bottomLeftTo: parent,
85+
),
86+
Text(
87+
'bottomCenter $index',
88+
style: style,
89+
).applyConstraint(
90+
bottomCenterTo: parent,
91+
),
92+
Text(
93+
'bottomRight $index',
94+
style: style,
95+
).applyConstraint(
96+
bottomRightTo: parent,
97+
)
98+
],
99+
),
100+
color: colors[index % 6],
101+
margin: const EdgeInsets.only(
102+
top: 10,
103+
),
104+
);
105+
},
106+
itemCount: 10000,
107+
itemExtent: 80,
108+
),
109+
),
110+
);
111+
}
112+
}

pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ dev_dependencies:
1818

1919
flutter:
2020
uses-material-design: false
21+
assets:
22+
- assets/test.png
23+
- assets/test2.png

0 commit comments

Comments
 (0)