@@ -13,6 +13,7 @@ class TreeNode extends StatefulWidget {
13
13
final bool showActions;
14
14
final bool contentTappable;
15
15
final double offsetLeft;
16
+ final double offsetRight;
16
17
final int ? maxLines;
17
18
18
19
final Function (TreeNodeData node) onTap;
@@ -52,13 +53,15 @@ class TreeNode extends StatefulWidget {
52
53
required this .onAppend,
53
54
required this .onRemove,
54
55
required this .onCollapse,
56
+ required this .offsetRight,
55
57
}) : super (key: key);
56
58
57
59
@override
58
60
_TreeNodeState createState () => _TreeNodeState ();
59
61
}
60
62
61
- class _TreeNodeState extends State <TreeNode > with SingleTickerProviderStateMixin {
63
+ class _TreeNodeState extends State <TreeNode >
64
+ with SingleTickerProviderStateMixin {
62
65
bool _isExpanded = false ;
63
66
bool _isChecked = false ;
64
67
bool _showLoading = false ;
@@ -77,6 +80,7 @@ class _TreeNodeState extends State<TreeNode> with SingleTickerProviderStateMixin
77
80
lazy: widget.lazy,
78
81
load: widget.load,
79
82
offsetLeft: widget.offsetLeft,
83
+ offsetRight: widget.offsetRight,
80
84
maxLines: widget.maxLines,
81
85
showCheckBox: widget.showCheckBox,
82
86
showActions: widget.showActions,
@@ -116,25 +120,30 @@ class _TreeNodeState extends State<TreeNode> with SingleTickerProviderStateMixin
116
120
Widget build (BuildContext context) {
117
121
if (widget.parentState != null ) _isChecked = widget.data.checked;
118
122
119
- bool hasData = widget.data.children.isNotEmpty || (widget.lazy && ! _isExpanded);
123
+ bool hasData =
124
+ widget.data.children.isNotEmpty || (widget.lazy && ! _isExpanded);
120
125
121
126
return Column (
122
127
crossAxisAlignment: CrossAxisAlignment .start,
123
128
children: < Widget > [
124
129
InkWell (
125
130
splashColor: widget.contentTappable ? null : Colors .transparent,
126
131
highlightColor: widget.contentTappable ? null : Colors .transparent,
127
- mouseCursor: widget.contentTappable ? SystemMouseCursors .click : MouseCursor .defer,
128
- onTap: widget.contentTappable ? () {
129
- if (hasData) {
130
- widget.onTap (widget.data);
131
- toggleExpansion ();
132
- } else {
133
- _isChecked = ! _isChecked;
134
- widget.onCheck (_isChecked, widget.data);
135
- setState (() {});
136
- }
137
- } : (){},
132
+ mouseCursor: widget.contentTappable
133
+ ? SystemMouseCursors .click
134
+ : MouseCursor .defer,
135
+ onTap: widget.contentTappable
136
+ ? () {
137
+ if (hasData) {
138
+ widget.onTap (widget.data);
139
+ toggleExpansion ();
140
+ } else {
141
+ _isChecked = ! _isChecked;
142
+ widget.onCheck (_isChecked, widget.data);
143
+ setState (() {});
144
+ }
145
+ }
146
+ : () {},
138
147
child: Container (
139
148
margin: const EdgeInsets .only (bottom: 2.0 ),
140
149
padding: const EdgeInsets .only (right: 12.0 ),
@@ -145,10 +154,12 @@ class _TreeNodeState extends State<TreeNode> with SingleTickerProviderStateMixin
145
154
child: IconButton (
146
155
iconSize: 16 ,
147
156
icon: hasData ? widget.icon : Container (),
148
- onPressed: hasData ? () {
149
- widget.onTap (widget.data);
150
- toggleExpansion ();
151
- } : null ,
157
+ onPressed: hasData
158
+ ? () {
159
+ widget.onTap (widget.data);
160
+ toggleExpansion ();
161
+ }
162
+ : null ,
152
163
),
153
164
turns: _turnsTween.animate (_rotationController),
154
165
),
@@ -198,7 +209,8 @@ class _TreeNodeState extends State<TreeNode> with SingleTickerProviderStateMixin
198
209
widget.remove (widget.data);
199
210
widget.onRemove (widget.data, widget.parent);
200
211
},
201
- child: const Text ('Remove' , style: TextStyle (fontSize: 12.0 )),
212
+ child:
213
+ const Text ('Remove' , style: TextStyle (fontSize: 12.0 )),
202
214
),
203
215
if (widget.data.customActions? .isNotEmpty == true )
204
216
...widget.data.customActions! ,
@@ -209,7 +221,8 @@ class _TreeNodeState extends State<TreeNode> with SingleTickerProviderStateMixin
209
221
SizeTransition (
210
222
sizeFactor: _rotationController,
211
223
child: Padding (
212
- padding: EdgeInsets .only (left: widget.offsetLeft),
224
+ padding: EdgeInsets .only (
225
+ left: widget.offsetLeft, right: widget.offsetRight),
213
226
child: Column (children: _geneTreeNodes (widget.data.children)),
214
227
),
215
228
)
0 commit comments