render method

void render ()

The method will change the DOM-Tree according to the _lane content

Implementation

void render() async {
  _updateVisualBar();
  _handlePowerUps();

  Map<int, Entity> visibleElements = _level.getVisibleEntities();

  Map<String, Element>.from(this._laneElements).forEach((id, e) async {
    int id = int.parse(e.id.substring(1));
    Entity entity;

    // update old DOM Element if its also in visibleElements
    if (visibleElements.containsKey(id)) {
      entity = visibleElements[id];
      _updateEntityElement(e, entity);
    } else {
      // otherwise delete it from [laneElements]
      e.remove();
      this._laneElements.remove(e.id);
    }
    // Remove handled entries
    visibleElements.remove(id);
  });

  // add new DOM Elements
  visibleElements.forEach((id, value) async {
    DivElement e = this._getEntityRepresentation(value);
    this._lane.append(e);
    this._laneElements.putIfAbsent("e" + id.toString(), () => e);
    _updateEntityElement(e, value);
  });
}