navigatorMiddleware<S> function

Iterable<Middleware<S>> navigatorMiddleware<S>(
  1. GlobalKey<NavigatorState> navigatorKey,
  2. {List<NavigatorMiddlewareBuilder<S, dynamic>> customBuilders = const []}
)

Returns list of Navigator controls related Middleware.

Implementation

Iterable<Middleware<S>> navigatorMiddleware<S>(
  /// The [GlobalKey] for [Navigator] that you use. You need to set
  /// the same [GlobalKey] for here and [MaterialApp] or [Navigator] that
  /// you use.
  GlobalKey<NavigatorState> navigatorKey, {

  /// A list of custom [NavigatorMiddlewareBuilder].
  ///
  /// You can add more behavior by giving list of custom
  /// [NavigatorMiddlewareBuilder]. If you specify no customBuilders,
  /// this method represents basic navigator related middleware.
  List<NavigatorMiddlewareBuilder<S, dynamic>> customBuilders = const [],
}) {
  assert(customBuilders != null);
  return InjectableMiddleware<S, GlobalKey<NavigatorState>>(
    builders: [
      ...basicNavigatorBuilders<S>(),
      ...customBuilders,
    ],
  )(navigatorKey);
}