jumpBackTo method

dynamic jumpBackTo(
  1. dynamic key
)

Jump back to key passed and clean all after

Implementation

jumpBackTo(dynamic key) {
  String old = stack.isNotEmpty ? stack.last.key : null;
  int index = -1;

  for (int i = 0; i < stack.length; i++) {
    final item = stack[i];

    if (item.key.toString() == key.toString()) {
      index = i;
      break;
    }
  }

  if (index > -1) {
    while (stack.length > index) {
      stack.removeLast();
    }

    _onBack(old, stack.last.key);

    _fragment.sink.add(stack.last);
  }
}