toStringList method
Implementation
Children toStringList(
{String prefix = '',
List<List<String>>? list,
Children? jsonObject,
int? tempIndex,
Attr? parent}) {
String selfPrefix = (next == null) ? '$prefix└─' : '$prefix├─';
String childPrefix = (next == null) ? '$prefix ' : '$prefix│ ';
if (previous == null && next != null) {
z = 0;
index = z;
} else if (previous != null && next == null) {
z += 1;
index = z;
z = 0;
} else if (previous != null && next != null) {
z += 1;
index = z;
} else {
index = 0;
}
bool check = false;
Offset offset = const Offset(0.0, 0.0);
try {
offset = (renderObject as RenderBox).localToGlobal(Offset.zero);
} catch (e) {
check = true;
Logger.d("${widget?.identity()} is not a object of RenderBox");
}
if (offset.dx < PxUtils().getScreenWidth && offset.dy < PxUtils().getScreenHeight) {
Attr attr = Attr();
if (!check) {
attr.x = offset.dx.toInt();
attr.y = offset.dy.toInt();
attr.h = size?.height.toInt();
attr.w = size?.width.toInt();
} else {
attr.x = 0;
attr.y = 0;
attr.h = 1;
attr.w = 1;
}
// get Element data in json format
String keyString = "";
if(key != null){
keyString = getKeyString(key);
}
int? totalChildren = children?.length;
if (isKeyStringDrawer(keyString) && !checkIfDrawerIsExpanded(element!)) {
jsonObject?.attr = Attr(x :0,y :0,h :0,w:0);
jsonObject?.children = [];
jsonObject?.type = widget?.identity();
totalChildren = 0 ;
}
else if((key != null && keyString.contains('hsl_ignore')) || ((widget is Visibility)
&& !(widget as Visibility).visible)){
jsonObject?.attr = Attr(x :0,y :0,h :0,w:0);
jsonObject?.children = [];
jsonObject?.type = widget?.identity();
totalChildren = 0 ;
} else{
jsonObject?.attr = attr;
jsonObject?.children = [];
for (int i = 0; i < totalChildren!; i++) {
jsonObject?.children?.add(Children());
}
if(widget is SmartechView){
jsonObject?.type = "SmartechView";
jsonObject?.eid = keyString;
} else {
jsonObject?.type = widget?.identity();
}
if (widget?.key is ValueKey || widget?.key is ObjectKey) {
jsonObject?.svix = keyString;
}
}
list?.add([
'${widget?.identity(prefix: selfPrefix)},'
' height: ${attr.h?.toStringAsFixed(2)}, width: ${attr.w?.toStringAsFixed(2)},'
' pox:${attr.x?.toStringAsFixed(2)}, poy:${attr.y?.toStringAsFixed(2)}, ix:$tempIndex, key : '
' $keyString, eid: ${keyString}',
]);
// traverse through children
int childIndex = -1;
for(int i=0;i<totalChildren;i++){
childIndex++;
children?.elementAt(i).toStringList(
list: list,
prefix: childPrefix,
jsonObject: jsonObject?.children![childIndex],
tempIndex: childIndex,
parent: attr);
}
}
return jsonObject!;
}