push method

E push(
  1. E element
)

Pushes an element onto the top of the stack.

Returns the element that was pushed.

Example:

final stack = LinkedStack<int>();
final pushed = stack.push(42);
print(pushed); // 42

Implementation

E push(E element) {
  final newNode = _StackNode<E>(element);
  newNode.next = _top;
  _top = newNode;
  _size++;
  return element;
}