pathfinding_dart 0.0.1

  • Example
  • Installing
  • Versions
  • new46

pBuild Status

pathfinding-dart - BSD LICENSE #

A pathfinding library written in dart, meant to be used for games. It is generic enough to be used in different kind of graphs (though, right now it only has implementation for grid graphs).

It is a port of my java library []. The java version was used in my old #1GAM january entry.

Intro #

The library works on a bunch of interfaces:

  • NavigationNode: this basically just represents a node of a graph. contains some getters and setters meant for navigation. Right now, only implementation is GridCell
  • NavigationGrap: a group of navigation nodes. Right now, only implementation is NavigationGrid
  • PathFinder: the implementation for the pathfinding algorithm, current options are:
    • AStarFinder
    • AStarGridFinder
    • JumpPointFinder (Currently broken)
    • ThetaStarFinder
    • ThetaStarGridFinder

Finders are fed with so called PathFinderOptions, which determine how the pathfinding will work (allowing diagonal movement, for example).

How to use #

You need to create a graph. Be aware that the NavigationGrid class, expects a bidimensional array of GridCell stored as [x][y]

//these should be stored as [x][y]
NavigationGridNode[][] nodes = new NavigationGridNode[5][5];
//create your cells with whatever data you need
nodes = createNodes();
//create a navigation grid with the cells you just created
NavigationGrid<NavigationGridNode> navGrid = new NavigationGrid(nodes);

Now, you need a finder which can work on your graph.

//create a finder either using the default options
AStarGridFinder<NavigationGridNode> finder = new AStarGridFinder();
//or create your own pathfinder options:
GridFinderOptions opt = new GridFinderOptions();
opt.allowDiagonal = false;
AStarGridFinder<GridCell> finder = new AStarGridFinder.withOptions(opt);

Once you have both, a graph and a finder, you can find paths within your graph at any time.

List<NavigationGridNode> pathToEnd = finder.findPath(0, 0, 4, 3, navGrid);

That's pretty much all there is to using the library.

0.0.1 #

  • Initial version, astar and thetastar finders are working


// import 'package:pathfinding_dart/pathfinding_dart.dart';

// main() {
//   var awesome = Awesome();
//   print('awesome: ${awesome.isAwesome}');
// }

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  pathfinding_dart: ^0.0.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:pathfinding_dart/pathfinding.dart';
import 'package:pathfinding_dart/pathfinding_grid.dart';
Version Uploaded Documentation Archive
0.0.1 Apr 9, 2019 Go to the documentation of pathfinding_dart 0.0.1 Download pathfinding_dart 0.0.1 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14


Detected platforms: Flutter, web, other

No platform restriction found in libraries.

Health suggestions

Fix lib/src/finders/thetastar_finder.dart. (-0.50 points)

Analysis of lib/src/finders/thetastar_finder.dart reported 1 hint:

line 3 col 1: Prefer using /// for doc comments.

Format lib/pathfinding.dart.

Run dartfmt to format lib/pathfinding.dart.

Format lib/pathfinding_grid.dart.

Run dartfmt to format lib/pathfinding_grid.dart.

Fix additional 8 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/bheap.dart (Run dartfmt to format lib/src/bheap.dart.)
  • lib/src/finders/astar_finder.dart (Run dartfmt to format lib/src/finders/astar_finder.dart.)
  • lib/src/grid/grid_finders.dart (Run dartfmt to format lib/src/grid/grid_finders.dart.)
  • lib/src/grid/grid_graph.dart (Run dartfmt to format lib/src/grid/grid_graph.dart.)
  • lib/src/grid/grid_node.dart (Run dartfmt to format lib/src/grid/grid_node.dart.)
  • lib/src/grid/heuristics.dart (Run dartfmt to format lib/src/grid/heuristics.dart.)
  • lib/src/interfaces.dart (Run dartfmt to format lib/src/interfaces.dart.)
  • lib/src/util.dart (Run dartfmt to format lib/src/util.dart.)

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

The package description is too short. (-8 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
Dev dependencies
build_runner ^1.0.0
build_test ^0.10.2
build_web_compilers ^0.4.0
pedantic ^1.0.0
test ^1.0.0
tweenengine ^0.12.1