getInstance static method

RouterProxy getInstance({
  1. RoutePathCallback? routePathCallback,
  2. ExitWindow? exitWindow,
  3. Map? pageMap,
  4. Widget? notFoundPage,
})

获取主路由实例(单例)

用于应用的主路由导航

示例:

final router = RouterProxy.getInstance(
  pageMap: {'/': HomePage()},
);

MaterialApp.router(
  routerDelegate: router,
  routeInformationParser: router.defaultParser(),
);

Implementation

static RouterProxy getInstance({
  RoutePathCallback? routePathCallback,
  ExitWindow? exitWindow,
  Map? pageMap,
  Widget? notFoundPage,
}) {
  _mainInstance ??= RouterProxy._(
    stackId: 'main',
    isMainStack: true,
    isDrawerStack: false,
    pathCallback: routePathCallback,
    exitWindow: exitWindow,
    pageMap: pageMap,
    notFoundPage: notFoundPage,
  );
  return _mainInstance!;
}