This repository contains a simple generic Stack implementation in Dart.
- Generic type support (
Stack<E>
) push()
→ Add an elementpop()
→ Remove and return the top element (safe, returns null if empty)peek()
→ View the top element without removing (safe, returns null if empty)isEmpty
→ Check if the stack is empty
- Clone the repository:
git clone https://github.com/ajlank/stack-array.git
cd stack-array
in main.dart
---------------
final s=Stack<int>();
s.push(1);
s.push(2);
s.push(3);
print(s.peek());
print(s.pop());
print(s.isEmpty);
From the terminal run-> dart main.dart