add method

dynamic add(
  1. dynamic value,
  2. dynamic cost
)

Add a new item to the queue and ensure the highest priority element is at the front of the queue.

Implementation

add(value, cost) {
  var item = {"value": value, "cost": cost};
  queue.add(item);
  queue.sort((a, b) {
    return a["cost"] - b["cost"];
  });
}