navigate<TState> method

void navigate<TState>(
  1. ValueKey<String> key, {
  2. Object? arguments,
  3. Object? pageScope,
})

Pushes a new page onto the stack and navigates to it. You must specify a the type of state so the StateHolder knows what to pass in.

Implementation

void navigate<TState>(
  ValueKey<String> key, {
  Object? arguments,
  Object? pageScope,
}) {
  assert(
    TState != dynamic,
    'You must specify a type argument for navigate. navigate passes the '
    'type argument to inherited widgets so the StateHolder '
    'can retrieve the state',
  );

  final materialPageBuilder = _pageBuildersByKey[key.value]!;

  final bloc = materialPageBuilder
      .blocBuilder()
      .build(arguments: arguments, pageScope: pageScope) as Bloc<TState>;

  _pageStack.push(
    _materialPage(key, pageScope, arguments, bloc, materialPageBuilder),
  );

  notifyListeners();
}