peekOrNull method
E?
peekOrNull()
Returns the top element of the stack without removing it.
Returns null if the stack is empty.
Example:
final stack = LinkedStack<String>();
print(stack.peekOrNull()); // null
stack.push('item');
print(stack.peekOrNull()); // 'item'
Implementation
E? peekOrNull() {
return _top?.data;
}