Skip to content

Commit ca158b8

Browse files
author
fbchen
committed
add license
1 parent 829f7f8 commit ca158b8

File tree

7 files changed

+244
-227
lines changed

7 files changed

+244
-227
lines changed

README.md

+141-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,147 @@
1-
# flutter_constraintlayout
1+
# Flutter ConstraintLayout
22

3-
constraintlayout for flutter
3+
Build flexible layouts with constraints, Similar to Android ConstraintLayout.
44

5-
## Getting Started
5+
# Example
66

7-
This project is a starting point for a Flutter application.
7+
```dart
8+
import 'package:flutter/material.dart';
9+
import 'package:flutter_constraintlayout/constrait_layout/constraint_layout.dart';
810
9-
A few resources to get you started if this is your first Flutter project:
11+
void main() {
12+
runApp(MaterialApp(
13+
home: Scaffold(
14+
backgroundColor: Colors.black,
15+
body: ConstraintLayout(
16+
children: [
17+
Constrained(
18+
id: 'box1',
19+
width: 200,
20+
height: 200,
21+
topToTop: CL.parent,
22+
rightToRight: CL.parent,
23+
child: Container(
24+
color: Colors.redAccent,
25+
alignment: Alignment.center,
26+
child: const Text('box1'),
27+
),
28+
),
29+
Constrained(
30+
id: 'box2',
31+
width: CL.matchConstraint,
32+
height: CL.matchConstraint,
33+
leftToLeft: 'box3',
34+
rightToRight: 'box3',
35+
topToBottom: 'box3',
36+
bottomToBottom: CL.parent,
37+
child: Container(
38+
color: Colors.blue,
39+
alignment: Alignment.center,
40+
child: const Text('box2'),
41+
),
42+
),
43+
Constrained(
44+
id: 'box4',
45+
width: 50,
46+
height: 50,
47+
rightToRight: CL.parent,
48+
bottomToBottom: CL.parent,
49+
child: Container(
50+
color: Colors.redAccent,
51+
alignment: Alignment.center,
52+
child: const Text('box4'),
53+
),
54+
),
55+
Constrained(
56+
id: 'box7',
57+
width: 120,
58+
height: 120,
59+
centerVertical: true,
60+
verticalBias: 0.5,
61+
leftToRight: 'box3',
62+
rightToRight: CL.parent,
63+
horizontalBias: 0.5,
64+
child: Container(
65+
color: Colors.lightGreen,
66+
alignment: Alignment.center,
67+
child: const Text('box7'),
68+
),
69+
),
70+
Constrained(
71+
id: 'box8',
72+
width: CL.matchConstraint,
73+
height: CL.matchConstraint,
74+
topToTop: 'box1',
75+
leftToLeft: CL.parent,
76+
rightToLeft: 'box3',
77+
bottomToBottom: CL.parent,
78+
margin: const EdgeInsets.all(50),
79+
child: Container(
80+
color: Colors.lightGreen,
81+
alignment: Alignment.center,
82+
child: const Text('box8'),
83+
),
84+
),
85+
Constrained(
86+
id: 'box3',
87+
width: CL.wrapContent,
88+
height: CL.wrapContent,
89+
rightToLeft: 'box1',
90+
topToBottom: 'box1',
91+
child: Container(
92+
color: Colors.orange,
93+
width: 200,
94+
height: 300,
95+
alignment: Alignment.center,
96+
child: const Text('box3'),
97+
),
98+
),
99+
Constrained(
100+
width: 100,
101+
height: 100,
102+
center: true,
103+
child: Container(
104+
color: Colors.pink,
105+
alignment: Alignment.center,
106+
child: const Text('child[6]'),
107+
),
108+
)
109+
],
110+
),
111+
),
112+
));
113+
}
114+
```
10115

11-
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12-
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
116+
![example.webp](https://github.com/hackware1993/flutter-constraintlayout/blob/master/effect.webp)
13117

14-
For help getting started with Flutter, view our
15-
[online documentation](https://flutter.dev/docs), which offers tutorials,
16-
samples, guidance on mobile development, and a full API reference.
118+
# Support me
119+
120+
If it helps you, consider sponsoring me a cup of milk tea
121+
![support.webp](https://github.com/hackware1993/flutter-constraintlayout/blob/master/support.webp)
122+
123+
# License
124+
125+
```
126+
MIT License
127+
128+
Copyright (c) 2016 hackware1993
129+
130+
Permission is hereby granted, free of charge, to any person obtaining a copy
131+
of this software and associated documentation files (the "Software"), to deal
132+
in the Software without restriction, including without limitation the rights
133+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
134+
copies of the Software, and to permit persons to whom the Software is
135+
furnished to do so, subject to the following conditions:
136+
137+
The above copyright notice and this permission notice shall be included in all
138+
copies or substantial portions of the Software.
139+
140+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
141+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
142+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
143+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
144+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
145+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
146+
SOFTWARE.
147+
```

effect.webp

4.27 KB
Binary file not shown.

lib/ConstraintLayoutDemo.dart

-139
This file was deleted.

0 commit comments

Comments
 (0)