sector 0.3.0+1 copy "sector: ^0.3.0+1" to clipboard
sector: ^0.3.0+1 copied to clipboard

Fast and intuitive 2D data structures: grids, graphs, pathfinding & more.

Sector #

Fast and intuitive 2D data structures: grids, graphs, pathfinding & more.

CI Deploy Coverage Status Pub Package Dartdoc reference

Preview of the Demo App

Live Demo | Latest API Docs

Getting Started #

Add a dependency in your pubspec.yaml or run the following command:

dart pub add sector

Features #

  • Platform independent, works on the Web, Flutter, and Dart VM.
  • Idiomatically Dart, with a familiar and fully documented API.
  • Extensible, with a focus on performance and ergonomics.
  • Well-tested, with 100% code coverage and property-based tests.
  • Lightweight, with zero dependencies, minimal overhead, and benchmarked.

Usage #

Sector offers a powerful toolkit for graphs, grids, pathfinding, and more.

Graphs #

Create a graph and add edges:

final graph = Graph<String>();

graph.addEdge(Edge('a', 'b'));
graph.addEdge(Edge('b', 'c'));

print(graph.roots); // ['a']
print(graph.successors('b')); // ['c']

Grids #

Create a grid and update cells:

enum Tile {
  wall,
  floor,
}

// Create a 5x8 grid filled with `Tile.wall`.
//
// When resizing a grid, the `empty` value is used to fill the new cells.
final grid = Grid.filled(5, 8, empty: Tile.wall);

// Itereate over the grid.
for (final row in grid.rows) {
  for (final cell in row) {
    print(cell);
  }
}

Pathfinding #

Use built-in pathfinding algorithms or write your own:

final graph = Walkable.linear(['a', 'b', 'c']);

final path = breadthFirstSearch(graph, 'a', Goal.node('c'));
print(path); // Path(['a', 'b', 'c'])

Contributing #

To run the tests, run:

dart test

To check code coverage locally, run:

dart pub global activate -sgit https://github.com/matanlurey/chore.dart.git --git-ref=8b252e7
chore coverage

To preview dartdoc output locally, run:

chore dartdoc
11
likes
150
pub points
0%
popularity

Publisher

verified publisherlurey.dev

Fast and intuitive 2D data structures: grids, graphs, pathfinding & more.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

lodim, meta

More

Packages that depend on sector