Skip to content

Commit 2c01d66

Browse files
committed
fix guideline offset
1 parent 3b228c0 commit 2c01d66

24 files changed

+682
-614
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
.history
1010
.svn/
1111

12+
lib/main.dart
13+
lib/src
14+
buildweb.sh
15+
pubspec.yaml
16+
1217
# IntelliJ related
1318
*.iml
1419
*.ipr

assets/3x/icon_back.webp

648 Bytes
Binary file not shown.

assets/3x/test.png

-430 KB
Binary file not shown.

assets/3x/test.webp

34.8 KB
Binary file not shown.

assets/3x/test2.png

-327 KB
Binary file not shown.

assets/3x/test2.webp

27.1 KB
Binary file not shown.

example/badge.dart

+33-30
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,46 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_constraintlayout/src/constraint_layout.dart';
33

4+
import 'custom_app_bar.dart';
5+
46
class BadgeExample extends StatelessWidget {
57
const BadgeExample({Key? key}) : super(key: key);
68

79
@override
810
Widget build(BuildContext context) {
911
ConstraintId anchor = ConstraintId('anchor');
10-
return MaterialApp(
11-
home: Scaffold(
12-
body: ConstraintLayout(
13-
children: [
14-
Container(
15-
color: Colors.yellow,
16-
).applyConstraint(
17-
width: 200,
18-
height: 200,
19-
centerTo: parent,
20-
id: anchor,
21-
),
22-
Container(
23-
color: Colors.green,
24-
child: const Text(
25-
'Indeterminate badge size',
26-
style: TextStyle(
27-
color: Colors.black,
28-
fontSize: 20,
29-
),
12+
return Scaffold(
13+
appBar: const CustomAppBar(
14+
title: 'Badge',
15+
),
16+
body: ConstraintLayout(
17+
children: [
18+
Container(
19+
color: Colors.yellow,
20+
).applyConstraint(
21+
width: 200,
22+
height: 200,
23+
centerTo: parent,
24+
id: anchor,
25+
),
26+
Container(
27+
color: Colors.green,
28+
child: const Text(
29+
'Indeterminate badge size',
30+
style: TextStyle(
31+
color: Colors.black,
32+
fontSize: 20,
3033
),
31-
).applyConstraint(
32-
width: wrapContent,
33-
height: wrapContent,
34-
left: anchor.right,
35-
bottom: anchor.top,
36-
translate: const Offset(-0.5, 0.5),
37-
percentageTranslate: true,
38-
)
39-
],
40-
),
34+
),
35+
).applyConstraint(
36+
width: wrapContent,
37+
height: wrapContent,
38+
left: anchor.right,
39+
bottom: anchor.top,
40+
translate: const Offset(-0.5, 0.5),
41+
percentageTranslate: true,
42+
)
43+
],
4144
),
4245
);
4346
}

example/barrier.dart

+48-45
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_constraintlayout/src/constraint_layout.dart';
33

4+
import 'custom_app_bar.dart';
5+
46
class BarrierExample extends StatelessWidget {
57
const BarrierExample({Key? key}) : super(key: key);
68

@@ -9,52 +11,53 @@ class BarrierExample extends StatelessWidget {
911
ConstraintId leftChild = ConstraintId('leftChild');
1012
ConstraintId rightChild = ConstraintId('rightChild');
1113
ConstraintId barrier = ConstraintId('barrier');
12-
return MaterialApp(
13-
home: Scaffold(
14-
body: ConstraintLayout(
15-
debugShowGuideline: true,
16-
children: [
17-
Container(
18-
color: const Color(0xFF005BBB),
19-
).applyConstraint(
20-
id: leftChild,
21-
width: 200,
22-
height: 200,
23-
top: parent.top,
24-
left: parent.left,
25-
),
26-
Container(
27-
color: const Color(0xFFFFD500),
28-
).applyConstraint(
29-
id: rightChild,
30-
width: 200,
31-
height: matchConstraint,
32-
right: parent.right,
33-
top: parent.top,
34-
bottom: parent.bottom,
35-
heightPercent: 0.5,
36-
verticalBias: 0,
37-
),
38-
Barrier(
39-
id: barrier,
40-
direction: BarrierDirection.bottom,
41-
referencedIds: [leftChild, rightChild],
14+
return Scaffold(
15+
appBar: const CustomAppBar(
16+
title: 'Barrier',
17+
),
18+
body: ConstraintLayout(
19+
debugShowGuideline: true,
20+
children: [
21+
Container(
22+
color: const Color(0xFF005BBB),
23+
).applyConstraint(
24+
id: leftChild,
25+
width: 200,
26+
height: 200,
27+
top: parent.top,
28+
left: parent.left,
29+
),
30+
Container(
31+
color: const Color(0xFFFFD500),
32+
).applyConstraint(
33+
id: rightChild,
34+
width: 200,
35+
height: matchConstraint,
36+
right: parent.right,
37+
top: parent.top,
38+
bottom: parent.bottom,
39+
heightPercent: 0.5,
40+
verticalBias: 0,
41+
),
42+
Barrier(
43+
id: barrier,
44+
direction: BarrierDirection.bottom,
45+
referencedIds: [leftChild, rightChild],
46+
),
47+
const Text(
48+
'Align to barrier',
49+
style: TextStyle(
50+
fontSize: 40,
51+
color: Colors.blue,
4252
),
43-
const Text(
44-
'Align to barrier',
45-
style: TextStyle(
46-
fontSize: 40,
47-
color: Colors.blue,
48-
),
49-
).applyConstraint(
50-
width: wrapContent,
51-
height: wrapContent,
52-
centerHorizontalTo: parent,
53-
top: barrier.bottom,
54-
goneMargin: const EdgeInsets.only(top: 20),
55-
)
56-
],
57-
),
53+
).applyConstraint(
54+
width: wrapContent,
55+
height: wrapContent,
56+
centerHorizontalTo: parent,
57+
top: barrier.bottom,
58+
goneMargin: const EdgeInsets.only(top: 20),
59+
)
60+
],
5861
),
5962
);
6063
}

0 commit comments

Comments
 (0)