import 'package:flutter/material.dart';

void navigateToRoute(BuildContext context, String targetRoute) {
  bool routeFound = false;

  Navigator.popUntil(context, (route) {
    if (route.settings.name == targetRoute) {
      routeFound = true;
      return true;
    }
    return route.isFirst;
  });

  if (!routeFound) {
    Navigator.pushNamed(context, targetRoute);
  }
}
