containsRoute method

Route? containsRoute({
  1. Route? route,
  2. RouteSettings? settings,
  3. String? name,
})

Implementation

Route? containsRoute({Route? route, RouteSettings? settings, String? name}){
  if(route != null){
    return routeHistory.contains(route) ? route : null;
  }
  if(settings != null){
    try{
      return routeHistory.firstWhere(
        (element) => element.settings == settings,
      );
    } catch (e){
      if(e is StateError){
        return null;
      }
    }
  }
  if(name != null){
    try{
      return routeHistory.firstWhere(
        (element) => element.settings.name == name,
      );
    } catch (e){
      if(e is StateError){
        return null;
      }
    }
  }
  return null;
}