put method

void put(
  1. AppRoute value
)

put the given route into the stack as the last route, replacing the route currently in that position. if the given route is already present further up the stack, then the stack is trimmed to that position instead. Note that this operation does not increase the stack depth.

Implementation

void put(AppRoute value) {
  final resolved = _resolved(value);
  if(resolved != null) {
    if(_stack.isEmpty) {
      _stack = [resolved];
      _changed();
    }
    else if(_stack.last != resolved) {
      int i = _stack.indexOf(resolved);
      if(i != -1) {
        _stack.removeRange(i + 1, _stack.length);
      } else {
        _stack.last = resolved;
      }
      _changed();
    }
  }
}