Skip to content

Commit f7c0a74

Browse files
committed
update example
1 parent fcc2936 commit f7c0a74

File tree

2 files changed

+44
-27
lines changed

2 files changed

+44
-27
lines changed

example/coming_soon.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_constraintlayout/src/constraint_layout.dart';
3+
4+
import 'custom_app_bar.dart';
5+
6+
class ComingSoonWidget extends StatelessWidget {
7+
const ComingSoonWidget({Key? key}) : super(key: key);
8+
9+
@override
10+
Widget build(BuildContext context) {
11+
return Scaffold(
12+
appBar: const CustomAppBar(
13+
title: 'Chain',
14+
),
15+
body: ConstraintLayout(
16+
children: [
17+
const Text('Coming soon, stay tuned').applyConstraint(
18+
centerTo: parent,
19+
)
20+
],
21+
),
22+
);
23+
}
24+
}

example/home.dart

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:flutter_constraintlayout/flutter_constraintlayout.dart';
44
import 'badge.dart';
55
import 'barrier.dart';
66
import 'circle_position.dart';
7+
import 'coming_soon.dart';
78
import 'complex_list.dart';
89
import 'dimension_ratio.dart';
910
import 'grid.dart';
@@ -34,7 +35,7 @@ class ExampleHome extends StatelessWidget {
3435
'Vertical List': const VerticalListExample(),
3536
'Staggered Grid': const StaggeredGridExample(),
3637
'Circle Position': const CirclePositionExample(),
37-
'Chain (Coming soon)': null,
38+
'Chain (Coming soon)': const ComingSoonWidget(),
3839
};
3940

4041
@override
@@ -53,32 +54,24 @@ class ExampleHome extends StatelessWidget {
5354
).applyConstraint(
5455
topCenterTo: parent,
5556
),
56-
SingleChildScrollView(
57-
child: Column(
58-
children: [
59-
for (int i = 0; i < keyList.length; i++)
60-
SizedBox(
61-
width: double.infinity,
62-
height: 40,
63-
child: TextButton(
64-
onPressed: exampleMap[keyList[i]] == null
65-
? null
66-
: () {
67-
Navigator.of(context)
68-
.push(MaterialPageRoute(builder: (_) {
69-
return exampleMap[keyList[i]]!;
70-
}));
71-
},
72-
child: Text(
73-
keyList[i],
74-
style: const TextStyle(
75-
fontSize: 20,
76-
),
77-
),
78-
),
79-
)
80-
],
81-
),
57+
ListView.builder(
58+
itemBuilder: (_, index) {
59+
return TextButton(
60+
onPressed: () {
61+
Navigator.of(context).push(MaterialPageRoute(builder: (_) {
62+
return exampleMap[keyList[index]]!;
63+
}));
64+
},
65+
child: Text(
66+
keyList[index],
67+
style: const TextStyle(
68+
fontSize: 20,
69+
),
70+
),
71+
);
72+
},
73+
itemCount: keyList.length,
74+
itemExtent: 40,
8275
).applyConstraint(
8376
width: matchParent,
8477
height: matchConstraint,

0 commit comments

Comments
 (0)