Skip to content

maybePop inside children #24

Open
Open

Description

@kirya355

Я люблю оборачивать несколько страниц в какой-то wrapper роут, чтобы у них был доступ к 1 инхериту.
Проблема в том что по дефолту в октопусе maybePop не смотрит на детей при удалении последнего, есть ли там дети или нет всегда удаляется весь последний роут.

Можно сделать новый метод или обновить существующий maybePop

Future<OctopusNode?> maybePopWithinChildren() {
    OctopusNode? result;
    return setState((state) {
      void removeLastInChildren(List<OctopusNode> children) {
        if (children.last.children.isEmpty) {
          children.removeLast();
          return;
        }

        return removeLastInChildren(children.last.children);
      }

      if (state.children.length < 2 && state.children.last.children.isEmpty) return state;

      removeLastInChildren(state.children);
      return state;
    }).then((_) => result);
  }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions