navigateWithProviders<R> method

Future<R?> navigateWithProviders<R>(
  1. Widget destination
)

Navigate to a new screen while preserving the current provider container

Implementation

Future<R?> navigateWithProviders<R>(Widget destination) {
  // Get the current provider container
  final container = ProviderScope.containerOf(context);

  return Navigator.of(context).push<R>(
    MaterialPageRoute(
      builder: (context) => UncontrolledProviderScope(
        container: container,
        child: destination,
      ),
    ),
  );
}