StandardPageWithNestedNavigatorFactory<T extends StandardPageWithNestedNavigator> class base

A factory class for creating StandardPageWithNestedNavigator pages with nested Navigators.

Nested navigators are useful for implementing applications with multiple navigation contexts, such as apps with footer menus where each tab maintains its own navigation stack.

This class can be added to the pages property of StandardMaterialApp.new or StandardCupertinoApp.new. T represents the type of the page that extends StandardPageWithNestedNavigator.

You can navigate to pages created by this factory using context.go<PageA, void>(null). When navigating to this page, if the nested page stack is empty, the first page from nestedPageFactories will be automatically pushed onto the nested Navigator.

You can also navigate directly to nested pages using context.go<NestedPageA, void>(null). When navigating to a nested page, this parent page will also be pushed onto the navigation stack.

When nested pages are popped and the nested page stack becomes empty, this parent page will also be automatically popped from the navigation stack.

Properties

The nestedPageFactories property defines the pages that will be displayed in each nested Navigator. At least one page factory must be specified in nestedPageFactories.

The anyNestedPageFactories property defines pages that can be used in any nested Navigator, allowing shared pages across different navigation contexts. When navigating to pages defined in anyNestedPageFactories, the navigation is performed against the currently active Navigator among the nested navigators. Pages added by anyNestedPageFactories are independent for each Navigator, and will not be moved to other Navigators by StandardPageNavigationMode.moveToTop.

The activeFirstNestedPage property controls whether the first page in nestedPageFactories is always stacked as the first page of the nested Navigator. The default value is true.

See also:

example:

StandardMaterialApp(
  onGenerateTitle: (context) => 'sample',
  pages: [
    StandardPageWithNestedNavigatorFactory<PageA>(
      create: (data) => PageA(),
      nestedPageFactories: [
        StandardPageFactory<NestedPageA, void>(
          create: (data) => NestedPageA(),
        ),
        StandardPageFactory<NestedPageB, void>(
          create: (data) => NestedPageB(),
        ),
      ],
    ),
  ],
);

class PageA extends StandardPageWithNestedNavigator {
  @override
  Widget buildPage(BuildContext context) {
    return nestedPages;
  }
}

class NestedPageA extends StandardPage<void> {
  @override
  Widget buildPage(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Nested Page A'),
      ),
      body: Text('Nested Page A Message'),
    );
  }
}

class NestedPageB extends StandardPage<void> {
  @override
  Widget buildPage(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Nested Page B'),
      ),
      body: Text('Nested Page B Message'),
    );
  }
}
Inheritance

Constructors

StandardPageWithNestedNavigatorFactory({required T create(void pageData), required List<StandardPageWithResultFactory<StandardPageWithResult<Object?, Object?>, Object?, Object?>> nestedPageFactories, List<StandardPageWithResultFactory<StandardPageWithResult<Object?, Object?>, Object?, Object?>> anyNestedPageFactories = const [], bool activeFirstNestedPage = true, bool enableNavigationAnalytics = false, Map<String, void Function(RegExpMatch match, Uri uri)>? links, String linkGenerator(void pageData)?, StandardPageBuilder<void, void>? pageBuilder, String? pageName()?})
Create a StandardPageWithNestedNavigatorFactory.
const

Properties

activeFirstNestedPage bool
Flag indicating whether the first page in nestedPageFactories should always be stacked as the first page of the nested Navigator.
final
anyNavigator bool
Add to the deepest navigator when there are multiple nested navigators.
no setterinherited
anyNestedPageFactories List<StandardPageWithResultFactory<StandardPageWithResult<Object?, Object?>, Object?, Object?>>
The list of nested pages that can be used in any nested Navigator.
final
childPageFactories List<StandardChildPageWithResultFactory<StandardPageWithResult<Object?, Object?>, Object?, Object?, Object?>>
The list of child pages that can be navigated to from this page.
finalinherited
create → T Function(void pageData)
Creates the T page that this factory manages.
finalinherited
dataType Type
The data type of this page.
no setterinherited
dataTypeIsNonNullable bool
Flag indicating that the type of page data set for this page is nullable.
no setterinherited
enableNavigationAnalytics bool
Flag indicating whether to enable analytics for navigation.
finalinherited
group String?
The group name used to manage multiple pages as part of the same group when they exist.
finalinherited
groupRoot bool
Flag indicating whether to set this page as the root group if a group name is specified.
finalinherited
hasChildPages bool
Flag indicating whether there are child pages that can be navigated to from this page.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
hasNestedPages bool
Flag indicating whether there are nested pages.
no setterinherited
keepHistory bool
Flag indicating whether to stack this page as part of the history or not.
finalinherited
linkGenerator String Function(void pageData)?
The function to create deep links for this page.
finalinherited
The method for transitioning to this page from other pages. Please refer to StandardPageNavigationMode for navigation modes.
finalinherited
The navigator page factory of this page, if any.
no setterinherited
nestedPageFactories List<StandardPageWithResultFactory<StandardPageWithResult<Object?, Object?>, Object?, Object?>>
The list of nested pages when using nested Navigators.
final
pageBuilder StandardPageBuilder<void, void>?
A function for creating StandardPageInterface.
finalinherited
pageDataWhenNull → void Function()?
A function to generate a replacement value when the pageData passed during navigation is null.
finalinherited
pageName String? Function()?
The name of this page.
finalinherited
pageType Type
The page type of this page.
no setterinherited
parentPageFactory StandardPageWithResultFactory<StandardPageWithResult<Object?, Object?>, Object?, Object?>?
The parent page factory of this page, if any.
no setterinherited
restorationId String Function(void pageData)?
A function for generating a value to pass to Page.restorationId.
finalinherited
resultType Type
The result type of this page.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createParentPageData(void pageData) Object?
When using child pages, specifies how to create the parent page data from the page data of this page.
inherited
Returns the deep link generated by this page for the given pageData.
inherited
getPageKey(Object? pageData) LocalKey
Get the key set for this page, as configured for this page.
inherited
goWithResult(void pageData, [StandardPageNavigationMode? navigationMode, bool pushParentPage = false]) Future<void>
Navigate to the StandardPage of type T with the option to pass pageData during navigation. An optional navigationMode representing the mode of StandardPageNavigationMode to use during navigation can also be provided. pushParentPage indicates whether to push the parent page when navigating to a child page. default is false.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited