NodeModel<T, E> constructor

NodeModel<T, E>({
  1. Vector2? position,
  2. String? id,
  3. T? data,
  4. List<NodeSocketModel<E>>? inputSockets,
  5. List<NodeSocketModel<E>>? outputSockets,
})

Implementation

NodeModel({
  Vector2? position,
  String? id,
  this.data,
  List<NodeSocketModel<E>>? inputSockets,
  List<NodeSocketModel<E>>? outputSockets,
}) {
  this.id = id ?? UniqueKey().toString();
  this.key = GlobalKey();
  this.position = position ?? Vector2.zero;
  this.inputSockets = inputSockets ?? [];
  this.outputSockets = outputSockets ?? [];
  if (this.inputSockets.isEmpty && this.outputSockets.isEmpty) {
    this.inputSockets.addAll([
      NodeSocketModel<E>(
        nodeId: this.id,
        id: UniqueKey().toString(),
        type: NodeSocketType.input,
        position: Vector2.zero,
      ),
    ]);
    this.outputSockets.addAll([
      NodeSocketModel<E>(
        nodeId: this.id,
        id: UniqueKey().toString(),
        type: NodeSocketType.output,
        position: Vector2.zero,
      ),
    ]);
  }
}