Skip to content

Commit bcc19bd

Browse files
author
fbchen
committed
add self wrapContent support
1 parent 05fca59 commit bcc19bd

File tree

5 files changed

+624
-286
lines changed

5 files changed

+624
-286
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ insult him.
9191
grid)
9292
17. circle position
9393
18. e-index(event dispatch order, default is z-index)
94+
19. self wrapContent
9495

9596
Coming soon:
9697

9798
1. chain
9899
2. constraints visualization
99-
3. self wrapContent
100-
4. more...
100+
3. more...
101101

102102
Support platform:
103103

example/home.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'guideline.dart';
1212
import 'horizontal_list.dart';
1313
import 'percentage_layout.dart';
1414
import 'relative_id.dart';
15+
import 'self_wrap_content.dart';
1516
import 'staggered_grid.dart';
1617
import 'summary.dart';
1718
import 'vertical_list.dart';
@@ -35,6 +36,7 @@ class ExampleHome extends StatelessWidget {
3536
'Vertical List': const VerticalListExample(),
3637
'Staggered Grid': const StaggeredGridExample(),
3738
'Circle Position': const CirclePositionExample(),
39+
'Self wrapContent': const SelfWrapContentExample(),
3840
'Chain (Coming soon)': const ComingSoonWidget(),
3941
};
4042

example/self_wrap_content.dart

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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 SelfWrapContentExample extends StatelessWidget {
7+
const SelfWrapContentExample({Key? key}) : super(key: key);
8+
9+
@override
10+
Widget build(BuildContext context) {
11+
return Scaffold(
12+
appBar: const CustomAppBar(
13+
title: 'Self wrapContent',
14+
codePath: 'example/self_wrap_content.dart',
15+
),
16+
body: Center(
17+
child: ConstraintLayout(
18+
width: wrapContent,
19+
height: wrapContent,
20+
children: [
21+
Container(
22+
color: Colors.blue,
23+
).applyConstraint(
24+
width: matchParent,
25+
height: matchParent,
26+
),
27+
Container(
28+
color: Colors.yellow,
29+
).applyConstraint(
30+
width: 300,
31+
height: 150,
32+
topLeftTo: parent,
33+
margin: const EdgeInsets.only(
34+
top: 10,
35+
left: 10,
36+
),
37+
),
38+
Container(
39+
color: Colors.orange,
40+
).applyConstraint(
41+
width: 50,
42+
height: 50,
43+
topRightTo: parent,
44+
),
45+
const Text(
46+
'Self wrapContent',
47+
).applyConstraint(
48+
outBottomRightTo: rId(1),
49+
margin: const EdgeInsets.only(
50+
left: 20,
51+
right: 20,
52+
),
53+
),
54+
Container(
55+
color: Colors.cyan,
56+
).applyConstraint(
57+
width: 50,
58+
height: 50,
59+
centerVerticalTo: parent,
60+
left: rId(1).right,
61+
right: rId(2).left,
62+
)
63+
],
64+
),
65+
),
66+
);
67+
}
68+
}

0 commit comments

Comments
 (0)