pop method
E
pop()
Removes and returns the top element of the stack.
Throws NoGuaranteeException if the stack is empty.
Example:
final stack = LinkedStack<String>();
stack.push('hello');
final popped = stack.pop(); // 'hello'
Implementation
E pop() {
if (_top == null) {
throw NoGuaranteeException('Stack is empty');
}
final data = _top!.data;
_top = _top!.next;
_size--;
return data;
}