maybeSetChildPages method

  1. @override
bool maybeSetChildPages(
  1. Iterable<PageContainer<Page>> pages
)
override

Attempts to handle a list of child pages.

Checks if the first route matches one of the child paths of this tab page. If it does, it sets that stack's pages to the routes, and switches the current index to that tab.

Implementation

@override
bool maybeSetChildPages(Iterable<PageContainer> pages) {
  assert(
    pages.isNotEmpty,
    "Don't call maybeSetPageStates with an empty list",
  );

  final tabPagePath = routeData.path;
  final subPagePath = pages.first.routeData.path;

  if (!pathContext.isWithin(tabPagePath, subPagePath)) {
    // subPagePath is not a path beneath the tab page's path.
    return false;
  }

  final index = _getIndexForPath(subPagePath);
  if (index == null) {
    // First route didn't match any of our child paths, so this isn't a route
    // that we can handle.
    return false;
  }

  // Handle route
  stacks[index].maybeSetChildPages(pages.toList());
  this.index = index;
  return true;
}