to method

List<PageSettings> to(
  1. String routeName, {
  2. Object? arguments,
  3. Map<String, String> queryParams = const {},
  4. bool isStrictMode = false,
})

Add the page of routeName to PageSettings

if isStrictMode is true and if the add page already exists in the route stack then all pages above the added page will be removed and the add page is displayed.

Implementation

List<PageSettings> to(
  String routeName, {
  Object? arguments,
  Map<String, String> queryParams = const {},
  bool isStrictMode = false,
}) {
  if (isStrictMode) {
    bool isThere = false;
    final l = where(
      (e) {
        if (e.name == routeName) {
          isThere = true;
        }
        return !isThere;
      },
    ).toList();
    l.add(PageSettings(
      name: routeName,
      arguments: arguments,
      queryParams: queryParams,
    ));
    return l;
  }
  add(PageSettings(
    name: routeName,
    arguments: arguments,
    queryParams: queryParams,
  ));
  return this;
}