toJson method
Convert to JSON-serializable map
Implementation
Map<String, dynamic> toJson() {
return {
'name': name,
'path': path,
'type': isDirectory ? 'directory' : 'file',
if (size != null) 'size': size,
if (isDirectory && children.isNotEmpty) 'children': children.map((c) => c.toJson()).toList(),
};
}