Skip to content

Commit 63ffe96

Browse files
committed
release v1.0.3-stable
1 parent b084c7c commit 63ffe96

File tree

4 files changed

+49
-15
lines changed

4 files changed

+49
-15
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# v1.0.3-stable
2+
3+
reduced constraint computation time to 0.01 ms for normal complexity layouts(10 child elements), 80%
4+
faster performance.
5+
16
# v1.0.2-stable
27

38
optimize layout performance.

README.md

+30-9
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,43 @@ No matter how complex the layout is and how deep the constraints are, it has alm
1212
performance as a single Flex or Stack. When facing complex layouts, it provides better performance,
1313
flexibility, and a very flat code hierarchy than Flex and Stack. Say no to 'nested hell'.
1414

15+
In short, once you use it, you can't go back.
16+
17+
Improving "nested hell" is one of my original intentions for developing Flutter ConstraintLayout,
18+
but I don't advocate the ultimate pursuit of one level of nesting, which is unnecessary. So features
19+
like chains are already well supported by Flex itself, so ConstraintLayout will not actively support
20+
it.
21+
1522
View [Flutter Web Online Example](https://constraintlayout.flutterfirst.cn)
1623

1724
**Flutter ConstraintLayout has extremely high layout performance. It does not require linear
18-
equations to solve. It is recommended to use ConstraintLayout at the top level. For extremely
19-
complex layout(One thousand child elements, two thousand constraints), layout and drawing total time
20-
within 5 milliseconds(debug mode on Windows 10,release mode take less time), the frame rate can be
21-
easily reached 200 fps.**
25+
equations to solve.** At any time, each child element will only be laid out once. When its own width
26+
or height is set to wrapContent, some child elements may calculate the offset twice. The layout
27+
process of ConstraintLayout consists of the following three steps:
28+
29+
1. Constraint calculation
30+
2. Layout
31+
3. Draw
32+
33+
The performance of layout and drawing is almost equivalent to a single Flex or Stack, and the
34+
performance of constraint calculation is roughly 0.01 milliseconds (layout of general complexity, 20
35+
child elements). Constraints are only recalculated after they have changed.
36+
37+
It is recommended to use ConstraintLayout at the top level. For extremely complex layout(one
38+
thousand child elements, two thousand constraints), layout and drawing total time within 5
39+
milliseconds(debug mode on Windows 10,release mode take less time), the frame rate can be easily
40+
reached 200 fps.
2241

2342
**If not necessary, try to be relative to the parent layout, so that you can define less id. Or use
2443
relative id.**
2544

2645
**Warning**:
2746
For layout performance considerations, constraints are always one-way, and there should be no two
28-
child elements directly or indirectly restrain each other. Each constraint should describe exactly
29-
where the child elements are located. Although constraints can only be one-way, you can still better
30-
handle things that were previously (Android ConstraintLayout) two-way constraints, such as chains.
47+
child elements directly or indirectly restrain each other(for example, the right side of A is
48+
constrained to the left side of B, and the left side of B is in turn constrained to A right). Each
49+
constraint should describe exactly where the child elements are located. Although constraints can
50+
only be one-way, you can still better handle things that were previously (Android ConstraintLayout)
51+
two-way constraints, such as chains(not yet supported, please use with Flex).
3152

3253
Anyone who sends you a harassing message, you can send him Flutter code and use 'nested hell' to
3354
insult him:
@@ -189,12 +210,12 @@ dependencies:
189210
flutter_constraintlayout:
190211
git:
191212
url: 'https://github.com/hackware1993/Flutter-ConstraintLayout.git'
192-
ref: 'v1.0.2-stable'
213+
ref: 'v1.0.3-stable'
193214
```
194215
195216
```yaml
196217
dependencies:
197-
flutter_constraintlayout: ^1.0.2-stable
218+
flutter_constraintlayout: ^1.0.3-stable
198219
```
199220
200221
```dart

README_CN.md

+13-5
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,17 @@ ConstraintLayout 不会积极支持它。
1717

1818
查看 [Flutter Web 在线示例](https://constraintlayout.flutterfirst.cn)
1919

20-
**Flutter ConstraintLayout 有极高的布局性能。它不基于 Cassowary 算法,无需线性方程求解。推荐在顶层使用
21-
ConstraintLayout。对于极端复杂的布局(1000 个子元素,2000 个约束),非首帧布局和绘制的总耗时在 5 毫秒内(在 Windows 10
22-
调试模式下,发布模式耗时更少),理论上首帧优势会更明显。对于常规复杂布局(50 个子元素,100 个约束),帧率可轻松达到 200 fps。**
20+
**Flutter ConstraintLayout 有极高的布局性能。它不基于 Cassowary 算法,无需线性方程求解。** 任何时候,每一个子元素都只会被 layout
21+
一次,当自身的宽或高被设置为 wrapContent 时,部分子元素可能会计算两次 offset。约束布局的布局过程包含以下三个步骤:
22+
23+
1. 约束计算
24+
2. 布局
25+
3. 绘制
26+
27+
其中布局和绘制的性能几乎与单一 Flex 或 Stack 相当,约束计算的性能大致为 0.01 毫秒(一般复杂度的布局,20 个子元素)。只有在约束变化后才会重新计算约束。
28+
29+
推荐在顶层使用 ConstraintLayout。对于极端复杂的布局(1000 个子元素,2000 个约束),非首帧布局和绘制的总耗时在 5 毫秒内(在 Windows 10
30+
调试模式下,发布模式耗时更少),理论上首帧优势会更明显。对于常规复杂布局(50 个子元素,100 个约束),帧率可轻松达到 200 fps。
2331

2432
**如非必要,尽量相对于 parent 布局,这样可以定义更少的 id,或者使用相对 id。**
2533

@@ -177,12 +185,12 @@ dependencies:
177185
flutter_constraintlayout:
178186
git:
179187
url: 'https://github.com/hackware1993/Flutter-ConstraintLayout.git'
180-
ref: 'v1.0.2-stable'
188+
ref: 'v1.0.3-stable'
181189
```
182190
183191
```yaml
184192
dependencies:
185-
flutter_constraintlayout: ^1.0.2-stable
193+
flutter_constraintlayout: ^1.0.3-stable
186194
```
187195
188196
```dart

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_constraintlayout
22
description: A super powerful Stack, build flexible layouts with constraints. Similar to ConstraintLayout for Android and AutoLayout for iOS. But the code implementation is much more efficient, it has O(n) layout time complexity and no linear equation solving is required.
3-
version: 1.0.2-stable
3+
version: 1.0.3-stable
44
anthor: hackware
55
homepage: https://github.com/hackware1993/Flutter-ConstraintLayout
66

0 commit comments

Comments
 (0)