-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSingleNode
More file actions
63 lines (54 loc) · 1.8 KB
/
SingleNode
File metadata and controls
63 lines (54 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import 'dart:convert';
import 'package:flutter/material.dart';
class SingleNode extends StatefulWidget {
SingleNode({
Key key,
@required this.fragmentPoolDateList,
@required this.fragmentPoolDateMap,
@required this.index,
}) : super(key: key);
final List<Map<dynamic, dynamic>> fragmentPoolDateList;
final Map<String, dynamic> fragmentPoolDateMap;
final int index;
@override
SingleNodeState createState() => SingleNodeState();
}
class SingleNodeState extends State<SingleNode> {
/// 获取 [布局大小]
void reGetLayoutSize() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
Map<dynamic, dynamic> listItem = widget.fragmentPoolDateList[widget.index];
widget.fragmentPoolDateMap[listItem["route"]]["this"] = this;
/// 获取 [布局大小]
Size size = (this.context.findRenderObject() as RenderBox).size;
widget.fragmentPoolDateMap[listItem["route"]]["layout_width"] = size.width;
widget.fragmentPoolDateMap[listItem["route"]]["layout_height"] = size.height;
});
}
@override
void initState() {
super.initState();
reGetLayoutSize();
}
@override
void didUpdateWidget(SingleNode oldWidget) {
super.didUpdateWidget(oldWidget);
reGetLayoutSize();
}
@override
Widget build(BuildContext context) {
return Positioned(
left: widget.fragmentPoolDateMap[widget.fragmentPoolDateList[widget.index]["route"]]["layout_left"] ?? 0.0,
top: widget.fragmentPoolDateMap[widget.fragmentPoolDateList[widget.index]["route"]]["layout_top"] ?? 0.0,
child: Container(
color: Colors.yellow,
child: FlatButton(
onPressed: () {
setState(() {});
},
child: Text(widget.fragmentPoolDateList[widget.index]["out_display_name"]),
),
),
);
}
}