buildComponentPageTree function

ViewerGroupPage buildComponentPageTree({
  1. required List<ViewerDocumentPage> componentPages,
  2. String id = 'components',
  3. bool compressLeaf = true,
  4. bool sortById = true,
})

Take a list of flat document pages and group & layer them into a single component tree. Typically you can pass the generated generatedComponentPages via flutter_design_codegen.

Implementation

ViewerGroupPage buildComponentPageTree({
  required List<ViewerDocumentPage> componentPages,

  /// Id of the component root node. This will also be converted to the node name.
  String id = 'components',

  /// See [buildGroupedPageTrees]
  bool compressLeaf = true,

  /// See [buildGroupedPageTrees]
  bool sortById = true,
}) {
  // Prepand the [id] to all namespaces of the generated component document pages
  return buildGroupedPageTrees(
    componentPages
        .map((e) => e.copyWith(namespace: [id, ...e.namespace]))
        .toList(),
    compressLeaf: compressLeaf,
    sortById: sortById,
  ).single;
}