Search packages, repositories and app categories

Package detailsv0.2.2

stack

A package for stack data structure. have the push, pop, size, length, and top functionalities.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
20.3K
Likes
38
Pub points
160

Install package

flutter pub add stack

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The stack package provides a simple and efficient implementation of the stack data structure in Dart, supporting core operations such as push, pop, size, length, and top. It is designed for developers who need a lightweight, reliable stack for managing last-in, first-out (LIFO) data workflows. The package is platform-agnostic, working seamlessly across Android, iOS, Web, macOS, Windows, and Linux. Ideal for algorithmic tasks, expression evaluation, or managing function call contexts, it integrates easily with Flutter and Dart projects via pub.dev.

Use cases

  • Implementing undo/redo functionality
  • Parsing expressions and syntax validation
  • Managing function call stacks
  • Handling nested structures
  • Backtracking algorithms

Key features

  • Push and pop operations
  • Access to top element
  • Size and length properties
  • Cross-platform compatibility
  • Minimal memory footprint

Suitable for

  • Dart developers needing LIFO data handling
  • Algorithm implementations
  • Educational projects
  • State management with LIFO logic
  • Lightweight utility needs

Considerations

  • Not suitable for FIFO operations
  • Limited to basic stack behavior
  • No built-in thread safety
  • Does not support custom comparators
  • Requires manual error handling for empty stack access

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

dart_stack

A dart package for stack datastructure

pub codecov CircleCI

Usage

Add dev dependency to your pubspec.yaml:

dev_dependencies:
  stack: ^0.0.1

Run pub get to install.

How it works

Import

import 'package:stack/stack.dart';

Example

// Initialize
Stack<String> stack = Stack();
// Push
stack.push('abc');
// See the top
stack.top();
// Pop the top
stack.pop();
// Check for empty
stack.isEmpty;
// Check for non-enpty
stack.isNotEmpty;
// see if the stack has a certain object
stack.contains("abc");
// print the complete stack
stack.print();
// get size of current stack
stack.size() || var s = stack.size()

Exceptions

Trying to use top() or pop() on an empty stack throws IllegalOperationException. use size(), isEmpty, or isNotEmpty to check before using these operations.

Feel free to file feature requests and bug reports at the issue tracker.

Categories

Source repository

Projects using this package