Skip to content

Commit 9ee5382

Browse files
Merge pull request #142 from BuildMirai/dv/stack-docs
docs: Add stack and positioned widgets documentation
2 parents 8dcbdd9 + 4031fd0 commit 9ee5382

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed

website/docs/widgets/positioned.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Positioned
2+
3+
The Mirai Positioned allows you to build a Flutter positioned widget using JSON.
4+
To know more about the positioned widget in Flutter, refer to the [official documentation](https://api.flutter.dev/flutter/widgets/Positioned-class.html).
5+
6+
## Properties
7+
8+
| Property | Type | Description |
9+
|----------------|-------------------------|---------------------------------------------------------------------------------------------|
10+
| positionedType | `MiraiPositionedType?` | The type of positioned widget. Can be `directional`, `fill`, or `fromRect`. |
11+
| left | `double?` | The distance from the left edge of the parent. |
12+
| top | `double?` | The distance from the top edge of the parent. |
13+
| right | `double?` | The distance from the right edge of the parent. |
14+
| bottom | `double?` | The distance from the bottom edge of the parent. |
15+
| width | `double?` | The width of the child. |
16+
| height | `double?` | The height of the child. |
17+
| start | `double?` | The distance from the start edge of the parent (for `directional` type). |
18+
| end | `double?` | The distance from the end edge of the parent (for `directional` type). |
19+
| textDirection | `TextDirection` | The text direction to use for resolving `start` and `end`. Defaults to `TextDirection.ltr`. |
20+
| rect | `MiraiRect?` | The rectangle to position the child (for `fromRect` type). |
21+
| child | `Map<String, dynamic>?` | The widget to display inside the positioned widget. |
22+
23+
## Example JSON
24+
25+
```json
26+
{
27+
"type": "positioned",
28+
"left": 10,
29+
"top": 20,
30+
"right": 30,
31+
"bottom": 40,
32+
"child": {
33+
"type": "text",
34+
"data": "Hello, World!"
35+
}
36+
}
37+
```
38+
39+
## Example JSON for `directional`
40+
41+
```json
42+
{
43+
"type": "positioned",
44+
"positionedType": "directional",
45+
"start": 10,
46+
"top": 20,
47+
"width": 100,
48+
"height": 50,
49+
"textDirection": "ltr",
50+
"child": {
51+
"type": "text",
52+
"data": "Hello, World!"
53+
}
54+
}
55+
```
56+
57+
### Example JSON for `fill`
58+
59+
```json
60+
{
61+
"type": "positioned",
62+
"positionedType": "fill",
63+
"left": 10,
64+
"top": 20,
65+
"right": 30,
66+
"bottom": 40,
67+
"child": {
68+
"type": "text",
69+
"data": "Hello, World!"
70+
}
71+
}
72+
```
73+
74+
### Example JSON for fromRect
75+
76+
```json
77+
{
78+
"type": "positioned",
79+
"positionedType": "fromRect",
80+
"rect": {
81+
"left": 10,
82+
"top": 20,
83+
"right": 110,
84+
"bottom": 70
85+
},
86+
"child": {
87+
"type": "text",
88+
"data": "Hello, World!"
89+
}
90+
}
91+
```

website/docs/widgets/stack.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Stack
2+
3+
The Mirai Stack allows you to build a Flutter stack widget using JSON.
4+
To know more about the stack widget in Flutter, refer to the [official documentation](https://api.flutter.dev/flutter/widgets/Stack-class.html).
5+
6+
## Properties
7+
8+
| Property | Type | Description |
9+
|---------------|------------------------------|----------------------------------------------------------------------------------------------------------------------|
10+
| alignment | `MiraiAlignmentDirectional` | How to align the non-positioned and partially-positioned children. Defaults to `MiraiAlignmentDirectional.topStart`. |
11+
| clipBehavior | `Clip` | How to clip the content. Defaults to `Clip.hardEdge`. |
12+
| fit | `StackFit` | How to size the non-positioned children. Defaults to `StackFit.loose`. |
13+
| textDirection | `TextDirection?` | The text direction to use for resolving alignment. |
14+
| children | `List<Map<String, dynamic>>` | The list of widgets to display inside the stack. Defaults to an empty list. |
15+
16+
## Example JSON
17+
18+
```json
19+
{
20+
"type": "stack",
21+
"alignment": "center",
22+
"clipBehavior": "antiAlias",
23+
"fit": "expand",
24+
"textDirection": "ltr",
25+
"children": [
26+
{
27+
"type": "text",
28+
"data": "Hello, World!"
29+
},
30+
{
31+
"type": "container",
32+
"width": 100,
33+
"height": 100,
34+
"color": "#FF0000"
35+
}
36+
]
37+
}
38+
```

0 commit comments

Comments
 (0)