NodeModel<T, E> constructor
NodeModel<T, E> ({
- Vector2? position,
- String? id,
- T? data,
- List<
NodeSocketModel< ? inputSockets,E> > - List<
NodeSocketModel< ? outputSockets,E> >
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,
),
]);
}
}