cleanupRemovedElements method

void cleanupRemovedElements(
  1. List<Point> points,
  2. List<AnimatedPointConnection> connections, [
  3. List<Satellite>? satellites
])

Clean up transitions for removed elements

Implementation

void cleanupRemovedElements(
    List<Point> points, List<AnimatedPointConnection> connections,
    [List<Satellite>? satellites]) {
  final pointIds = points.map((p) => p.id).toSet();
  final connectionIds = connections.map((c) => c.id).toSet();

  _pointTransitions.removeWhere((key, _) => !pointIds.contains(key));
  _connectionTransitions
      .removeWhere((key, _) => !connectionIds.contains(key));
  _dashOffsets.removeWhere((key, _) => !connectionIds.contains(key));

  if (satellites != null) {
    final satelliteIds = satellites.map((s) => s.id).toSet();
    _satelliteTransitions
        .removeWhere((key, _) => !satelliteIds.contains(key));
    // Also cleanup orbit path cache
    _orbitPathCache.removeWhere((key, _) => !satelliteIds.contains(key));
  }
}