navigateTo<T extends Object?> method Null safety

  1. @override
Future<T?> navigateTo<T extends Object?>(
  1. {required String location,
  2. Object? arguments}

Navigate to the following location.

location to navigate to. Must be unique in the current navigation stack.

arguments to pass at the location.


Future<T?> navigateTo<T extends Object?>({
  required final String location,
  final Object? arguments,
}) async {
  assert(location.trim().isNotEmpty, 'destination location is empty');

  final Destination destination = Destination(
    path: location,
    metadata: DestinationMetadata(
      arguments: arguments,
      history: page) => page.destination).toList(),

  final DBPage? newPage = await _pageBuilders.getPage(destination);

  if (newPage == null) {
    throw PageNotFoundException(destination);


  final Completer<T?> popTracker = Completer<T?>();
  _popResultTracker[destination.path] = popTracker;


  final T? result = await popTracker.future;

  return result;