final _commonParentChildrenMap = {
'Animated Feature Films': [
OptionGroup([
'Cinderalla',
'Alice In Wonderland',
'Peter Pan',
'Lady and the Tramp',
])
],
'Live-Action Films': [
OptionGroup(
['Treasure Island', 'The Littlest Outlaw', 'Old Yeller', 'Star Wars'])
],
'Documentary Films': [
OptionGroup(['Frank and Ollie', 'Sacred Planet'])
],
'Star Wars': [
OptionGroup(['By George Lucas'])
],
'By George Lucas': [
OptionGroup(['A New Hope', 'Empire Strikes Back', 'Return of the Jedi'])
]
};
/// An example data set of hierarchical data.
final SelectionOptions nestedOptions = _NestedSelectionOptions([
OptionGroup(
['Animated Feature Films', 'Live-Action Films', 'Documentary Films'])
], _commonParentChildrenMap);
/// A slight restructure of [nestedOptions] to separate "Animated Feature Films"
/// with the other two option groups.
final SelectionOptions nestedOptionsVariation = _NestedSelectionOptions([
OptionGroup(['Animated Feature Films']),
OptionGroup(['Live-Action Films']),
OptionGroup(['Documentary Films']),
], _commonParentChildrenMap);
/// An example implementation of [SelectionOptions] with [Parent].
class _NestedSelectionOptions extends SelectionOptions
implements Parent<T, List<OptionGroup>> {
final Map<T, List<OptionGroup>> _children;
I am looking why material-tree is displaying nothing. Here is my code
For Component
@Component( selector: 'tree-root', directives: [MaterialTreeComponent], templateUrl: 'tree_component.html', styleUrls: ['tree_component.css'], changeDetection: ChangeDetectionStrategy.OnPush, ) class TreeComponent {
final SelectionOptions nestedOptions = data.nestedOptions;
ItemRenderer childItemRenderer = (String childTitle)=>childTitle.toUpperCase();
String itemRenderer(item) =>childItemRenderer(item);
@ViewChild(MaterialTreeComponent) MaterialTreeComponent materialTree; }
For tree Options
final _commonParentChildrenMap = { 'Animated Feature Films': [ OptionGroup([ 'Cinderalla', 'Alice In Wonderland', 'Peter Pan', 'Lady and the Tramp', ]) ], 'Live-Action Films': [ OptionGroup( ['Treasure Island', 'The Littlest Outlaw', 'Old Yeller', 'Star Wars']) ], 'Documentary Films': [ OptionGroup(['Frank and Ollie', 'Sacred Planet']) ], 'Star Wars': [ OptionGroup(['By George Lucas']) ], 'By George Lucas': [ OptionGroup(['A New Hope', 'Empire Strikes Back', 'Return of the Jedi']) ] };
/// An example data set of hierarchical data. final SelectionOptions nestedOptions = _NestedSelectionOptions([ OptionGroup( ['Animated Feature Films', 'Live-Action Films', 'Documentary Films']) ], _commonParentChildrenMap);
/// A slight restructure of [nestedOptions] to separate "Animated Feature Films" /// with the other two option groups. final SelectionOptions nestedOptionsVariation = _NestedSelectionOptions([ OptionGroup(['Animated Feature Films']), OptionGroup(['Live-Action Films']), OptionGroup(['Documentary Films']), ], _commonParentChildrenMap);
/// An example implementation of [SelectionOptions] with [Parent]. class _NestedSelectionOptions extends SelectionOptions
implements Parent<T, List<OptionGroup>> {
final Map<T, List<OptionGroup>> _children;
_NestedSelectionOptions(List<OptionGroup> options, this._children)
: super(options);
@override bool hasChildren(T item) => _children.containsKey(item);
@override DisposableFuture<List<OptionGroup>> childrenOf(T parent, [_]) {
print("$_children");
return DisposableFuture<List<OptionGroup>>.fromValue(_children[parent]);
}
}