Skip to main content
This class defines how a route should be built and displayed, including the URL pattern, page builder, and optional metadata.

Properties

label
String?
Optional label for the route, used for named navigation.
url
String
required
The URL pattern for this route. Must start with ’/’. Supports path parameters using ’:’ syntax, e.g., ‘/user/:id’.
builder
NavigationPageFactory
required
Function that builds the widget for this route.
pageType
PageType?
The type of page transition to use.
fullScreenDialog
bool?
Whether this route should be displayed as a fullscreen dialog.
barrierColor
Color?
The barrier color for modal routes.
metadata
Map<String, dynamic>
default:"{}"
Optional metadata associated with this route.
pageBuilder
CustomPageBuilder?
Optional custom page builder for this route. If provided, this takes precedence over the default page building logic.
group
String?
Routes can be grouped together by setting a common group name. By default, Flutter identifies routes with unique URLs as unique pages. Setting a group alias overrides the default behavior and identifies those routes as the same page.
uri
Uri
The parsed URI from url.
path
String
The canonical path from url.
queryParameters
Map<String, String>
The query parameters extracted from url.

Constructor

NavigationData({
  String? label,
  required String url,
  required NavigationPageFactory builder,
  PageType? pageType,
  bool? fullScreenDialog,
  Color? barrierColor,
  Map<String, dynamic> metadata = const {},
  String? group,
  CustomPageBuilder? pageBuilder
})
label
String?
Optional label for named navigation.
url
String
required
The URL pattern. Must start with ’/’.
builder
NavigationPageFactory
required
Function that builds the widget for this route.
pageType
PageType?
The type of page transition to use.
fullScreenDialog
bool?
Whether to display as a fullscreen dialog.
barrierColor
Color?
The barrier color for modal routes.
metadata
Map<String, dynamic>
default:"{}"
Optional metadata.
group
String?
Optional group name for grouping related routes.
pageBuilder
CustomPageBuilder?
Optional custom page builder.

Type definitions

typedef NavigationPageFactory = Widget Function(
  BuildContext context,
  DefaultRoute routeData,
  Map<String, dynamic> globalData
)
Function type for building navigation pages. This function is called to build the widget for a given route.

CustomPageBuilder

typedef CustomPageBuilder = Page Function(
  ValueKey<String>? key,
  String? name,
  Widget child,
  DefaultRoute routeData,
  Map<String, dynamic> globalData,
  Object? arguments
)
Function type for custom page building. Allows custom creation of Page objects with full control over the page configuration.

OnUnknownRoute

typedef OnUnknownRoute = Page Function(DefaultRoute route)
Function type for handling unknown routes. Called when a route is not found in the navigation routes. Should return a Page to display for the unknown route.

Enums

PageType

Types of page transitions available for navigation.
  • material - Material Design page transition (default)
  • transparent - Transparent page transition (allows underlying page to show through)
  • cupertino - Cupertino (iOS-style) page transition

Example

NavigationData(
  label: 'home',
  url: '/home',
  builder: (context, routeData, globalData) => HomePage(),
  pageType: PageType.material,
)

// With path parameters
NavigationData(
  label: 'user-detail',
  url: '/user/:id',
  builder: (context, routeData, globalData) {
    final userId = routeData.pathParameters['id'];
    return UserDetailPage(userId: userId);
  },
)

// With group for tabbed navigation
NavigationData(
  label: 'games',
  url: '/games',
  builder: (context, routeData, globalData) => HomePage(tab: 'games'),
  group: 'home',
)

Build docs developers (and LLMs) love