Node Data not being written when TreeViewController is converted back to a Map

Issue #34 resolved
Former user created an issue

My use case involves loading a dynamic map into a TreeView for rendering and then reverting the latest state of the TreeView back to a map periodically.

My initial Map data contains the <Map>data property for each node. Now the TreeViewController seems to be loading the Map properly and I’m able to access the data property of each node just fine through the TreeViewController. But when I revert the TreeViewController back to a Map using the .asMap method, all the Node properties in the TreeViewController’s children are converted to a map but the data property.

To highlight my issue here’s some code and corresponding console logs that might help provide a little more insight:

TreeViewController _treeViewController = TreeViewController();
print("MAP: ${context.read<UserLibrary>().folderTree}");

_treeViewController = _treeViewController.loadMap(
list: context.read<UserLibrary>().folderTree);
print("MAP AS TREE VIEW CONTROLLER: ${_treeViewController.children}");

print("Data property accessed from _treeViewController: ${_treeViewController.children[0].data}");
print("Data property seems to be missing when the _treeViewController is converted back to a map:\n${_treeViewController.asMap[0]["data"]}");

Output:

I/flutter (12389): MAP: [{key: ROOT/, label: Folders, data: {folderColour: 4282215352, paperCount: 0}, 
children: [{key: ROOT/Medicine/, label: Medicine, data: {folderColour: 4287346431, paperCount: 0}, 
children: [{key: ROOT/Medicine/Neuroscience/, label: Neuroscience, data: {folderColour: 4287346431, 
paperCount: 0}}]}, {key: ROOT/Machine Learning/, label: Machine Learning, data: {folderColour: 4287346431, 
paperCount: 0}, children: [{key: ROOT/Machine Learning/Deep Learning/, label: Deep Learning, data: 
{folderColour: 4287346431, paperCount: 0}}]}]}]

I/flutter (12389): MAP AS TREE VIEW CONTROLLER: [{"key":"ROOT/","label":"Folders","icon":null,
"expanded":false,"parent":false,"children":[{"key":"ROOT/Medicine/","label":"Medicine","icon":null,
"expanded":false,"parent":false,"children":[{"key":"ROOT/Medicine/Neuroscience/","label":"Neuroscience",
"icon":null,"expanded":false,"parent":false,"children":[]}]},{"key":"ROOT/Machine Learning/",
"label":"Machine Learning","icon":null,"expanded":false,"parent":false,
"children":[{"key":"ROOT/Machine Learning/Deep Learning/","label":"Deep Learning","icon":null,
"expanded":false,"parent":false,"children":[]}]}]}]

I/flutter (12389): Data property accessed from _treeViewController: {folderColour: 4282215352, paperCount: 0}

I/flutter (12389): Data property seems to be missing when the _treeViewController is converted back 
to a map: null

Is it possible to have the .asMap fully convert all the nodes and their sub-nodes and so forth into Maps, while including the data property too?

Comments (1)

  1. Log in to comment