ForceSimulation.withDefaults constructor

ForceSimulation.withDefaults({
  1. required List<NetworkNode> nodes,
  2. required List<NetworkLink> links,
  3. double centerX = 0,
  4. double centerY = 0,
  5. double chargeStrength = -30,
  6. double linkDistance = 30,
  7. void onTick()?,
  8. void onEnd()?,
})

Creates a simulation with default forces.

Implementation

factory ForceSimulation.withDefaults({
  required List<NetworkNode> nodes,
  required List<NetworkLink> links,
  double centerX = 0,
  double centerY = 0,
  double chargeStrength = -30,
  double linkDistance = 30,
  void Function()? onTick,
  void Function()? onEnd,
}) {
  return ForceSimulation(
    nodes: nodes,
    links: links,
    forces: [
      CenterForce(x: centerX, y: centerY),
      ManyBodyForce(strength: chargeStrength),
      LinkForce(links: links, distance: linkDistance),
    ],
    onTick: onTick,
    onEnd: onEnd,
  );
}