sector 0.3.0-alpha+1 copy "sector: ^0.3.0-alpha+1" to clipboard
sector: ^0.3.0-alpha+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 Coverage Status Pub Package Dartdoc reference

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 tool/coverage.dart

To preview dartdoc output locally, run:

dart tool/dartdoc.dart
12
likes
0
points
35
downloads

Publisher

verified publisherlurey.dev

Weekly Downloads

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

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

lodim, meta

More

Packages that depend on sector