replaceWithProviders<R> method

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

Replace the current screen while preserving the current provider container

Implementation

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

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